OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Note: this file is used by Aura on all linux platforms, even though it | 5 // Note: this file is used by Aura on all linux platforms, even though it |
6 // is currently in a chromeos specific location. | 6 // is currently in a chromeos specific location. |
7 | 7 |
8 #include "chrome/browser/chromeos/status/memory_menu_button.h" | 8 #include "chrome/browser/chromeos/status/memory_menu_button.h" |
9 | 9 |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/process_util.h" // GetSystemMemoryInfo | 12 #include "base/process_util.h" // GetSystemMemoryInfo |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/chromeos/view_ids.h" | 15 #include "chrome/browser/chromeos/view_ids.h" |
16 #include "chrome/browser/memory_purger.h" | 16 #include "chrome/browser/memory_purger.h" |
17 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
18 #include "content/browser/renderer_host/render_process_host.h" | |
19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
| 20 #include "content/public/browser/render_process_host.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
23 #include "views/controls/menu/menu_runner.h" | 23 #include "views/controls/menu/menu_runner.h" |
24 #include "views/widget/widget.h" | 24 #include "views/widget/widget.h" |
25 | 25 |
26 #if defined(USE_TCMALLOC) | 26 #if defined(USE_TCMALLOC) |
27 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" | 27 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(USE_TCMALLOC) | 30 #if defined(USE_TCMALLOC) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return filepath; | 153 return filepath; |
154 } | 154 } |
155 #endif | 155 #endif |
156 } | 156 } |
157 | 157 |
158 void MemoryMenuButton::SendCommandToRenderers(int id) { | 158 void MemoryMenuButton::SendCommandToRenderers(int id) { |
159 #if defined(USE_TCMALLOC) | 159 #if defined(USE_TCMALLOC) |
160 // Use the "is running" value for this process to determine whether to | 160 // Use the "is running" value for this process to determine whether to |
161 // start or stop profiling on the renderer processes. | 161 // start or stop profiling on the renderer processes. |
162 bool started = IsHeapProfilerRunning(); | 162 bool started = IsHeapProfilerRunning(); |
163 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 163 for (content::RenderProcessHost::iterator it = |
| 164 content::RenderProcessHost::AllHostsIterator(); |
164 !it.IsAtEnd(); it.Advance()) { | 165 !it.IsAtEnd(); it.Advance()) { |
165 switch (id) { | 166 switch (id) { |
166 case TOGGLE_PROFILING_ITEM: | 167 case TOGGLE_PROFILING_ITEM: |
167 it.GetCurrentValue()->Send(new ChromeViewMsg_SetTcmallocHeapProfiling( | 168 it.GetCurrentValue()->Send(new ChromeViewMsg_SetTcmallocHeapProfiling( |
168 started, std::string(kProfileDumpFilePrefix))); | 169 started, std::string(kProfileDumpFilePrefix))); |
169 break; | 170 break; |
170 case DUMP_PROFILING_ITEM: | 171 case DUMP_PROFILING_ITEM: |
171 it.GetCurrentValue()->Send(new ChromeViewMsg_WriteTcmallocHeapProfile( | 172 it.GetCurrentValue()->Send(new ChromeViewMsg_WriteTcmallocHeapProfile( |
172 GetProfileDumpFilePath( | 173 GetProfileDumpFilePath( |
173 base::GetProcId(it.GetCurrentValue()->GetHandle())))); | 174 base::GetProcId(it.GetCurrentValue()->GetHandle())))); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 256 } |
256 | 257 |
257 ///////////////////////////////////////////////////////////////////////////// | 258 ///////////////////////////////////////////////////////////////////////////// |
258 // content::NotificationObserver overrides. | 259 // content::NotificationObserver overrides. |
259 | 260 |
260 void MemoryMenuButton::Observe(int type, | 261 void MemoryMenuButton::Observe(int type, |
261 const content::NotificationSource& source, | 262 const content::NotificationSource& source, |
262 const content::NotificationDetails& details) { | 263 const content::NotificationDetails& details) { |
263 switch (type) { | 264 switch (type) { |
264 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 265 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
265 RenderProcessHost::RendererClosedDetails* process_details = | 266 content::RenderProcessHost::RendererClosedDetails* process_details = |
266 content::Details<RenderProcessHost::RendererClosedDetails>(details). | 267 content::Details<content::RenderProcessHost::RendererClosedDetails>( |
267 ptr(); | 268 details).ptr(); |
268 if (process_details->status == | 269 if (process_details->status == |
269 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 270 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
270 renderer_kills_++; | 271 renderer_kills_++; |
271 // A kill is a very interesting event, so repaint immediately. | 272 // A kill is a very interesting event, so repaint immediately. |
272 UpdateText(); | 273 UpdateText(); |
273 } | 274 } |
274 break; | 275 break; |
275 } | 276 } |
276 default: | 277 default: |
277 NOTREACHED() << L"Received unexpected notification"; | 278 NOTREACHED() << L"Received unexpected notification"; |
278 break; | 279 break; |
279 } | 280 } |
280 } | 281 } |
OLD | NEW |