| 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 #include "chrome/browser/chromeos/status/memory_menu_button.h" | 5 #include "chrome/browser/chromeos/status/memory_menu_button.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/process_util.h" // GetSystemMemoryInfo | 9 #include "base/process_util.h" // GetSystemMemoryInfo |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 12 #include "chrome/browser/chromeos/status/status_area_host.h" | 12 #include "chrome/browser/chromeos/status/status_area_host.h" |
| 13 #include "chrome/browser/memory_purger.h" | 13 #include "chrome/browser/memory_purger.h" |
| 14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
| 15 #include "content/browser/renderer_host/render_process_host.h" | 15 #include "content/browser/renderer_host/render_process_host.h" |
| 16 #include "content/common/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "views/controls/menu/menu_runner.h" | 20 #include "views/controls/menu/menu_runner.h" |
| 21 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 22 | 22 |
| 23 #if defined(USE_TCMALLOC) | 23 #if defined(USE_TCMALLOC) |
| 24 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" | 24 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" |
| 25 #endif | 25 #endif |
| 26 | 26 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 51 // Delay between updates, in seconds. | 51 // Delay between updates, in seconds. |
| 52 const int kUpdateIntervalSeconds = 5; | 52 const int kUpdateIntervalSeconds = 5; |
| 53 | 53 |
| 54 MemoryMenuButton::MemoryMenuButton(StatusAreaHost* host) | 54 MemoryMenuButton::MemoryMenuButton(StatusAreaHost* host) |
| 55 : StatusAreaButton(host, this), | 55 : StatusAreaButton(host, this), |
| 56 meminfo_(new base::SystemMemoryInfoKB()), | 56 meminfo_(new base::SystemMemoryInfoKB()), |
| 57 renderer_kills_(0) { | 57 renderer_kills_(0) { |
| 58 // Track renderer kills, as the kernel OOM killer will start to kill our | 58 // Track renderer kills, as the kernel OOM killer will start to kill our |
| 59 // renderers as we run out of memory. | 59 // renderers as we run out of memory. |
| 60 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 60 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 61 NotificationService::AllSources()); | 61 content::NotificationService::AllSources()); |
| 62 UpdateTextAndSetNextTimer(); | 62 UpdateTextAndSetNextTimer(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 MemoryMenuButton::~MemoryMenuButton() { | 65 MemoryMenuButton::~MemoryMenuButton() { |
| 66 } | 66 } |
| 67 | 67 |
| 68 void MemoryMenuButton::UpdateTextAndSetNextTimer() { | 68 void MemoryMenuButton::UpdateTextAndSetNextTimer() { |
| 69 UpdateText(); | 69 UpdateText(); |
| 70 | 70 |
| 71 timer_.Start(FROM_HERE, | 71 timer_.Start(FROM_HERE, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 break; | 272 break; |
| 273 } | 273 } |
| 274 default: | 274 default: |
| 275 NOTREACHED() << L"Received unexpected notification"; | 275 NOTREACHED() << L"Received unexpected notification"; |
| 276 break; | 276 break; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace chromeos | 280 } // namespace chromeos |
| OLD | NEW |