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 #ifndef CHROME_BROWSER_TASK_MANAGER_BROWSER_PROCESS_RESOURCE_PROVIDER_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_BROWSER_PROCESS_RESOURCE_PROVIDER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "chrome/browser/task_manager/resource_provider.h" 11 #include "content/public/browser/browser_child_process_observer.h" 12 #include "content/public/browser/child_process_data.h" 13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/render_view_host_observer.h" 16 #include "content/public/common/process_type.h" 17 18 class TaskManager; 19 20 namespace content { 21 class RenderViewHost; 22 class WebContents; 23 } 24 25 namespace extensions { 26 class Extension; 27 } 28 29 namespace task_manager { 30 31 class BrowserProcessResource : public Resource { 32 public: 33 BrowserProcessResource(); 34 virtual ~BrowserProcessResource(); 35 36 // Resource methods: 37 virtual string16 GetTitle() const OVERRIDE; 38 virtual string16 GetProfileName() const OVERRIDE; 39 virtual gfx::ImageSkia GetIcon() const OVERRIDE; 40 virtual base::ProcessHandle GetProcess() const OVERRIDE; 41 virtual int GetUniqueChildProcessId() const OVERRIDE; 42 virtual Type GetType() const OVERRIDE; 43 44 virtual bool SupportNetworkUsage() const OVERRIDE; 45 virtual void SetSupportNetworkUsage() OVERRIDE; 46 47 virtual bool ReportsSqliteMemoryUsed() const OVERRIDE; 48 virtual size_t SqliteMemoryUsedBytes() const OVERRIDE; 49 50 virtual bool ReportsV8MemoryStats() const OVERRIDE; 51 virtual size_t GetV8MemoryAllocated() const OVERRIDE; 52 virtual size_t GetV8MemoryUsed() const OVERRIDE; 53 54 private: 55 base::ProcessHandle process_; 56 mutable string16 title_; 57 58 static gfx::ImageSkia* default_icon_; 59 60 DISALLOW_COPY_AND_ASSIGN(BrowserProcessResource); 61 }; 62 63 class BrowserProcessResourceProvider : public ResourceProvider { 64 public: 65 explicit BrowserProcessResourceProvider(TaskManager* task_manager); 66 67 virtual Resource* GetResource(int origin_pid, 68 int render_process_host_id, 69 int routing_id) OVERRIDE; 70 virtual void StartUpdating() OVERRIDE; 71 virtual void StopUpdating() OVERRIDE; 72 73 // Whether we are currently reporting to the task manager. Used to ignore 74 // notifications sent after StopUpdating(). 75 bool updating_; 76 77 private: 78 virtual ~BrowserProcessResourceProvider(); 79 80 TaskManager* task_manager_; 81 BrowserProcessResource resource_; 82 83 DISALLOW_COPY_AND_ASSIGN(BrowserProcessResourceProvider); 84 }; 85 86 } // namespace task_manager 87 88 #endif // CHROME_BROWSER_TASK_MANAGER_BROWSER_PROCESS_RESOURCE_PROVIDER_H_ 89