Home | History | Annotate | Download | only in task_manager
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/task_manager/os_resource_win.h"
      6 
      7 namespace task_manager {
      8 
      9 void GetWinGDIHandles(base::ProcessHandle process,
     10                       size_t* current,
     11                       size_t* peak) {
     12   *current = 0;
     13   *peak = 0;
     14   // Get a handle to |process| that has PROCESS_QUERY_INFORMATION rights.
     15   HANDLE current_process = GetCurrentProcess();
     16   HANDLE process_with_query_rights;
     17   if (DuplicateHandle(current_process, process, current_process,
     18                       &process_with_query_rights, PROCESS_QUERY_INFORMATION,
     19                       false, 0)) {
     20     *current = GetGuiResources(process_with_query_rights, GR_GDIOBJECTS);
     21     *peak = GetGuiResources(process_with_query_rights, GR_GDIOBJECTS_PEAK);
     22     CloseHandle(process_with_query_rights);
     23   }
     24 }
     25 
     26 void GetWinUSERHandles(base::ProcessHandle process,
     27                        size_t* current,
     28                        size_t* peak) {
     29   *current = 0;
     30   *peak = 0;
     31   // Get a handle to |process| that has PROCESS_QUERY_INFORMATION rights.
     32   HANDLE current_process = GetCurrentProcess();
     33   HANDLE process_with_query_rights;
     34   if (DuplicateHandle(current_process, process, current_process,
     35                       &process_with_query_rights, PROCESS_QUERY_INFORMATION,
     36                       false, 0)) {
     37     *current = GetGuiResources(process_with_query_rights, GR_USEROBJECTS);
     38     *peak = GetGuiResources(process_with_query_rights, GR_USEROBJECTS_PEAK);
     39     CloseHandle(process_with_query_rights);
     40   }
     41 }
     42 
     43 }  // namespace task_manager
     44