| 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/view_ids.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/public/browser/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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 #endif | 44 #endif |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 namespace chromeos { | 49 namespace chromeos { |
| 50 | 50 |
| 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(StatusAreaButton::Delegate* delegate) |
| 55 : StatusAreaButton(host, this), | 55 : StatusAreaButton(delegate, this), |
| 56 meminfo_(new base::SystemMemoryInfoKB()), | 56 meminfo_(new base::SystemMemoryInfoKB()), |
| 57 renderer_kills_(0) { | 57 renderer_kills_(0) { |
| 58 set_id(VIEW_ID_STATUS_BUTTON_MEMORY); |
| 58 // Track renderer kills, as the kernel OOM killer will start to kill our | 59 // Track renderer kills, as the kernel OOM killer will start to kill our |
| 59 // renderers as we run out of memory. | 60 // renderers as we run out of memory. |
| 60 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 61 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 61 content::NotificationService::AllSources()); | 62 content::NotificationService::AllSources()); |
| 62 UpdateTextAndSetNextTimer(); | 63 UpdateTextAndSetNextTimer(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 MemoryMenuButton::~MemoryMenuButton() { | 66 MemoryMenuButton::~MemoryMenuButton() { |
| 66 } | 67 } |
| 67 | 68 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 272 } |
| 272 break; | 273 break; |
| 273 } | 274 } |
| 274 default: | 275 default: |
| 275 NOTREACHED() << L"Received unexpected notification"; | 276 NOTREACHED() << L"Received unexpected notification"; |
| 276 break; | 277 break; |
| 277 } | 278 } |
| 278 } | 279 } |
| 279 | 280 |
| 280 } // namespace chromeos | 281 } // namespace chromeos |
| OLD | NEW |