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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/process_util.h" // GetSystemMemoryInfo | 8 #include "base/process_util.h" // GetSystemMemoryInfo |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 NotificationService::AllSources()); | 59 NotificationService::AllSources()); |
60 UpdateTextAndSetNextTimer(); | 60 UpdateTextAndSetNextTimer(); |
61 } | 61 } |
62 | 62 |
63 MemoryMenuButton::~MemoryMenuButton() { | 63 MemoryMenuButton::~MemoryMenuButton() { |
64 } | 64 } |
65 | 65 |
66 void MemoryMenuButton::UpdateTextAndSetNextTimer() { | 66 void MemoryMenuButton::UpdateTextAndSetNextTimer() { |
67 UpdateText(); | 67 UpdateText(); |
68 | 68 |
69 timer_.Start(FROM_HERE, | 69 timer_.Start(base::TimeDelta::FromSeconds(kUpdateIntervalSeconds), this, |
70 base::TimeDelta::FromSeconds(kUpdateIntervalSeconds), this, | |
71 &MemoryMenuButton::UpdateTextAndSetNextTimer); | 70 &MemoryMenuButton::UpdateTextAndSetNextTimer); |
72 } | 71 } |
73 | 72 |
74 void MemoryMenuButton::UpdateText() { | 73 void MemoryMenuButton::UpdateText() { |
75 base::GetSystemMemoryInfo(meminfo_.get()); | 74 base::GetSystemMemoryInfo(meminfo_.get()); |
76 // "Anonymous" memory, meaning not mapped to a file (which has a name), | 75 // "Anonymous" memory, meaning not mapped to a file (which has a name), |
77 // represents memory that has been dynamically allocated to a process. | 76 // represents memory that has been dynamically allocated to a process. |
78 // It thus approximates heap memory usage across all processes. | 77 // It thus approximates heap memory usage across all processes. |
79 int anon_kb = meminfo_->active_anon + meminfo_->inactive_anon; | 78 int anon_kb = meminfo_->active_anon + meminfo_->inactive_anon; |
80 std::wstring label = base::StringPrintf(L"%d MB (%d)", | 79 std::wstring label = base::StringPrintf(L"%d MB (%d)", |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 261 } |
263 break; | 262 break; |
264 } | 263 } |
265 default: | 264 default: |
266 NOTREACHED() << L"Received unexpected notification"; | 265 NOTREACHED() << L"Received unexpected notification"; |
267 break; | 266 break; |
268 } | 267 } |
269 } | 268 } |
270 | 269 |
271 } // namespace chromeos | 270 } // namespace chromeos |
OLD | NEW |