Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/task_manager/browser_process_resource_provider.cc

Issue 15196003: Create task_manager namespace and wrap classes related to TaskManager with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RendererResource Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/task_manager/task_manager_browser_process_resource_prov ider.h" 5 #include "chrome/browser/task_manager/browser_process_resource_provider.h"
6 6
7 #include "base/basictypes.h"
8 #include "base/command_line.h" 7 #include "base/command_line.h"
9 #include "base/string16.h" 8 #include "base/string16.h"
10 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
11 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
13 #include "net/proxy/proxy_resolver_v8.h" 12 #include "net/proxy/proxy_resolver_v8.h"
14 #include "third_party/sqlite/sqlite3.h" 13 #include "third_party/sqlite/sqlite3.h"
15 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
18 17
19 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
20 #include "ui/gfx/image/image_skia_util_mac.h" 19 #include "ui/gfx/image/image_skia_util_mac.h"
21 #endif // defined(OS_MACOSX) 20 #endif // defined(OS_MACOSX)
22 21
23 #if defined(OS_WIN) 22 #if defined(OS_WIN)
24 #include "chrome/browser/app_icon_win.h" 23 #include "chrome/browser/app_icon_win.h"
25 #include "ui/gfx/icon_util.h" 24 #include "ui/gfx/icon_util.h"
26 #endif // defined(OS_WIN) 25 #endif // defined(OS_WIN)
27 26
28 //////////////////////////////////////////////////////////////////////////////// 27 namespace task_manager {
29 // TaskManagerBrowserProcessResource class
30 ////////////////////////////////////////////////////////////////////////////////
31 28
32 gfx::ImageSkia* TaskManagerBrowserProcessResource::default_icon_ = NULL; 29 gfx::ImageSkia* BrowserProcessResource::default_icon_ = NULL;
33 30
34 TaskManagerBrowserProcessResource::TaskManagerBrowserProcessResource() 31 BrowserProcessResource::BrowserProcessResource()
35 : title_() { 32 : title_() {
36 int pid = base::GetCurrentProcId(); 33 int pid = base::GetCurrentProcId();
37 bool success = base::OpenPrivilegedProcessHandle(pid, &process_); 34 bool success = base::OpenPrivilegedProcessHandle(pid, &process_);
38 DCHECK(success); 35 DCHECK(success);
39 #if defined(OS_WIN) 36 #if defined(OS_WIN)
40 if (!default_icon_) { 37 if (!default_icon_) {
41 HICON icon = GetAppIcon(); 38 HICON icon = GetAppIcon();
42 if (icon) { 39 if (icon) {
43 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon)); 40 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
44 default_icon_ = new gfx::ImageSkia( 41 default_icon_ = new gfx::ImageSkia(
(...skipping 12 matching lines...) Expand all
57 // conversion :-(). 54 // conversion :-().
58 default_icon_ = new gfx::ImageSkia(gfx::ApplicationIconAtSize(16)); 55 default_icon_ = new gfx::ImageSkia(gfx::ApplicationIconAtSize(16));
59 } 56 }
60 #else 57 #else
61 // TODO(port): Port icon code. 58 // TODO(port): Port icon code.
62 NOTIMPLEMENTED(); 59 NOTIMPLEMENTED();
63 #endif // defined(OS_WIN) 60 #endif // defined(OS_WIN)
64 default_icon_->MakeThreadSafe(); 61 default_icon_->MakeThreadSafe();
65 } 62 }
66 63
67 TaskManagerBrowserProcessResource::~TaskManagerBrowserProcessResource() { 64 BrowserProcessResource::~BrowserProcessResource() {
68 base::CloseProcessHandle(process_); 65 base::CloseProcessHandle(process_);
69 } 66 }
70 67
71 // TaskManagerResource methods: 68 // TaskManagerResource methods:
72 string16 TaskManagerBrowserProcessResource::GetTitle() const { 69 string16 BrowserProcessResource::GetTitle() const {
73 if (title_.empty()) { 70 if (title_.empty()) {
74 title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT); 71 title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT);
75 } 72 }
76 return title_; 73 return title_;
77 } 74 }
78 75
79 string16 TaskManagerBrowserProcessResource::GetProfileName() const { 76 string16 BrowserProcessResource::GetProfileName() const {
80 return string16(); 77 return string16();
81 } 78 }
82 79
83 gfx::ImageSkia TaskManagerBrowserProcessResource::GetIcon() const { 80 gfx::ImageSkia BrowserProcessResource::GetIcon() const {
84 return *default_icon_; 81 return *default_icon_;
85 } 82 }
86 83
87 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { 84 size_t BrowserProcessResource::SqliteMemoryUsedBytes() const {
88 return static_cast<size_t>(sqlite3_memory_used()); 85 return static_cast<size_t>(sqlite3_memory_used());
89 } 86 }
90 87
91 base::ProcessHandle TaskManagerBrowserProcessResource::GetProcess() const { 88 base::ProcessHandle BrowserProcessResource::GetProcess() const {
92 return base::GetCurrentProcessHandle(); // process_; 89 return base::GetCurrentProcessHandle(); // process_;
93 } 90 }
94 91
95 int TaskManagerBrowserProcessResource::GetUniqueChildProcessId() const { 92 int BrowserProcessResource::GetUniqueChildProcessId() const {
96 return 0; 93 return 0;
97 } 94 }
98 95
99 TaskManager::Resource::Type TaskManagerBrowserProcessResource::GetType() const { 96 TaskManager::Resource::Type BrowserProcessResource::GetType() const {
100 return BROWSER; 97 return BROWSER;
101 } 98 }
102 99
103 bool TaskManagerBrowserProcessResource::SupportNetworkUsage() const { 100 bool BrowserProcessResource::SupportNetworkUsage() const {
104 return true; 101 return true;
105 } 102 }
106 103
107 void TaskManagerBrowserProcessResource::SetSupportNetworkUsage() { 104 void BrowserProcessResource::SetSupportNetworkUsage() {
108 NOTREACHED(); 105 NOTREACHED();
109 } 106 }
110 107
111 bool TaskManagerBrowserProcessResource::ReportsSqliteMemoryUsed() const { 108 bool BrowserProcessResource::ReportsSqliteMemoryUsed() const {
112 return true; 109 return true;
113 } 110 }
114 111
115 // BrowserProcess uses v8 for proxy resolver in certain cases. 112 // BrowserProcess uses v8 for proxy resolver in certain cases.
116 bool TaskManagerBrowserProcessResource::ReportsV8MemoryStats() const { 113 bool BrowserProcessResource::ReportsV8MemoryStats() const {
117 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 114 const CommandLine* command_line = CommandLine::ForCurrentProcess();
118 bool using_v8 = !command_line->HasSwitch(switches::kWinHttpProxyResolver); 115 bool using_v8 = !command_line->HasSwitch(switches::kWinHttpProxyResolver);
119 if (using_v8 && command_line->HasSwitch(switches::kSingleProcess)) { 116 if (using_v8 && command_line->HasSwitch(switches::kSingleProcess)) {
120 using_v8 = false; 117 using_v8 = false;
121 } 118 }
122 return using_v8; 119 return using_v8;
123 } 120 }
124 121
125 size_t TaskManagerBrowserProcessResource::GetV8MemoryAllocated() const { 122 size_t BrowserProcessResource::GetV8MemoryAllocated() const {
126 return net::ProxyResolverV8::GetTotalHeapSize(); 123 return net::ProxyResolverV8::GetTotalHeapSize();
127 } 124 }
128 125
129 size_t TaskManagerBrowserProcessResource::GetV8MemoryUsed() const { 126 size_t BrowserProcessResource::GetV8MemoryUsed() const {
130 return net::ProxyResolverV8::GetUsedHeapSize(); 127 return net::ProxyResolverV8::GetUsedHeapSize();
131 } 128 }
132 129
133 //////////////////////////////////////////////////////////////////////////////// 130 ////////////////////////////////////////////////////////////////////////////////
134 // TaskManagerBrowserProcessResourceProvider class 131 // BrowserProcessResourceProvider class
135 //////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////
136 133
137 TaskManagerBrowserProcessResourceProvider:: 134 BrowserProcessResourceProvider::
138 TaskManagerBrowserProcessResourceProvider(TaskManager* task_manager) 135 BrowserProcessResourceProvider(TaskManager* task_manager)
139 : updating_(false), 136 : updating_(false),
140 task_manager_(task_manager) { 137 task_manager_(task_manager) {
141 } 138 }
142 139
143 TaskManagerBrowserProcessResourceProvider:: 140 BrowserProcessResourceProvider::~BrowserProcessResourceProvider() {
144 ~TaskManagerBrowserProcessResourceProvider() {
145 } 141 }
146 142
147 TaskManager::Resource* TaskManagerBrowserProcessResourceProvider::GetResource( 143 TaskManager::Resource* BrowserProcessResourceProvider::GetResource(
148 int origin_pid, 144 int origin_pid,
149 int render_process_host_id, 145 int render_process_host_id,
150 int routing_id) { 146 int routing_id) {
151 if (origin_pid || render_process_host_id != -1) { 147 if (origin_pid || render_process_host_id != -1) {
152 return NULL; 148 return NULL;
153 } 149 }
154 150
155 return &resource_; 151 return &resource_;
156 } 152 }
157 153
158 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 154 void BrowserProcessResourceProvider::StartUpdating() {
159 task_manager_->AddResource(&resource_); 155 task_manager_->AddResource(&resource_);
160 } 156 }
161 157
162 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 158 void BrowserProcessResourceProvider::StopUpdating() {
163 } 159 }
160
161 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698