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

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

Issue 543045: Be more frugal with goats in these challenging economic times. (Closed)
Patch Set: link to design doc Created 10 years, 11 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
« no previous file with comments | « chrome/browser/task_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/browser/task_manager.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 FormatBytes(stat.size, DATA_UNITS_KIBIBYTE, false), 57 FormatBytes(stat.size, DATA_UNITS_KIBIBYTE, false),
58 FormatBytes(stat.liveSize, DATA_UNITS_KIBIBYTE, false)); 58 FormatBytes(stat.liveSize, DATA_UNITS_KIBIBYTE, false));
59 } 59 }
60 60
61 } // namespace 61 } // namespace
62 62
63 //////////////////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////////////
64 // TaskManagerModel class 64 // TaskManagerModel class
65 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
66 66
67 // static
68 int TaskManagerModel::goats_teleported_ = 0;
69
70 TaskManagerModel::TaskManagerModel(TaskManager* task_manager) 67 TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
71 : update_state_(IDLE) { 68 : update_state_(IDLE) {
72 69
73 TaskManagerBrowserProcessResourceProvider* browser_provider = 70 TaskManagerBrowserProcessResourceProvider* browser_provider =
74 new TaskManagerBrowserProcessResourceProvider(task_manager); 71 new TaskManagerBrowserProcessResourceProvider(task_manager);
75 browser_provider->AddRef(); 72 browser_provider->AddRef();
76 providers_.push_back(browser_provider); 73 providers_.push_back(browser_provider);
77 TaskManagerTabContentsResourceProvider* wc_provider = 74 TaskManagerTabContentsResourceProvider* wc_provider =
78 new TaskManagerTabContentsResourceProvider(task_manager); 75 new TaskManagerTabContentsResourceProvider(task_manager);
79 wc_provider->AddRef(); 76 wc_provider->AddRef();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return IntToWString(base::GetProcId(resources_[index]->GetProcess())); 162 return IntToWString(base::GetProcId(resources_[index]->GetProcess()));
166 } 163 }
167 164
168 std::wstring TaskManagerModel::GetResourceStatsValue(int index, int col_id) 165 std::wstring TaskManagerModel::GetResourceStatsValue(int index, int col_id)
169 const { 166 const {
170 DCHECK(index < ResourceCount()); 167 DCHECK(index < ResourceCount());
171 return IntToWString(GetStatsValue(resources_[index], col_id)); 168 return IntToWString(GetStatsValue(resources_[index], col_id));
172 } 169 }
173 170
174 std::wstring TaskManagerModel::GetResourceGoatsTeleported(int index) const { 171 std::wstring TaskManagerModel::GetResourceGoatsTeleported(int index) const {
172 // See design doc at http://go/at-teleporter for more information.
175 DCHECK(index < ResourceCount()); 173 DCHECK(index < ResourceCount());
176 goats_teleported_ += rand() & 4095; 174 int goats_teleported = rand() & 15;
177 return UTF16ToWide(base::FormatNumber(goats_teleported_)); 175 return UTF16ToWide(base::FormatNumber(goats_teleported));
178 } 176 }
179 177
180 std::wstring TaskManagerModel::GetResourceWebCoreImageCacheSize( 178 std::wstring TaskManagerModel::GetResourceWebCoreImageCacheSize(
181 int index) const { 179 int index) const {
182 DCHECK(index < ResourceCount()); 180 DCHECK(index < ResourceCount());
183 if (!resources_[index]->ReportsCacheStats()) 181 if (!resources_[index]->ReportsCacheStats())
184 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT); 182 return l10n_util::GetString(IDS_TASK_MANAGER_NA_CELL_TEXT);
185 const WebKit::WebCache::ResourceTypeStats stats( 183 const WebKit::WebCache::ResourceTypeStats stats(
186 resources_[index]->GetWebCoreCacheStats()); 184 resources_[index]->GetWebCoreCacheStats());
187 return FormatStatsSize(stats.images); 185 return FormatStatsSize(stats.images);
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 // or popup, we can only have one tab, hence we need to process this in a 912 // or popup, we can only have one tab, hence we need to process this in a
915 // tabbed browser window. Currently, |browser| is pointing to the application, 913 // tabbed browser window. Currently, |browser| is pointing to the application,
916 // popup window. Therefore, we have to retrieve the last active tab again, 914 // popup window. Therefore, we have to retrieve the last active tab again,
917 // since a new window has been used. 915 // since a new window has been used.
918 if (browser->type() & Browser::TYPE_APP_POPUP) { 916 if (browser->type() & Browser::TYPE_APP_POPUP) {
919 browser = BrowserList::GetLastActive(); 917 browser = BrowserList::GetLastActive();
920 DCHECK(browser); 918 DCHECK(browser);
921 } 919 }
922 browser->window()->Show(); 920 browser->window()->Show();
923 } 921 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698