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

Unified Diff: chrome/browser/task_manager/task_manager.cc

Issue 3597016: Expands the chrome.experimental.processes extension API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/task_manager/task_manager.h ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/task_manager/task_manager.cc
===================================================================
--- chrome/browser/task_manager/task_manager.cc (revision 61514)
+++ chrome/browser/task_manager/task_manager.cc (working copy)
@@ -70,7 +70,8 @@
////////////////////////////////////////////////////////////////////////////////
TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
- : update_state_(IDLE),
+ : update_requests_(0),
+ update_state_(IDLE),
goat_salt_(rand()) {
TaskManagerBrowserProcessResourceProvider* browser_provider =
@@ -119,9 +120,13 @@
return WideToUTF16Hack(resources_[index]->GetTitle());
}
+int64 TaskManagerModel::GetNetworkUsage(int index) const {
+ DCHECK(index < ResourceCount());
+ return GetNetworkUsage(resources_[index]);
+}
+
string16 TaskManagerModel::GetResourceNetworkUsage(int index) const {
- DCHECK(index < ResourceCount());
- int64 net_usage = GetNetworkUsage(resources_[index]);
+ int64 net_usage = GetNetworkUsage(index);
if (net_usage == -1)
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
if (net_usage == 0)
@@ -132,6 +137,11 @@
return base::i18n::GetDisplayStringInLTRDirectionality(net_byte);
}
+double TaskManagerModel::GetCPUUsage(int index) const {
+ DCHECK(index < ResourceCount());
+ return GetCPUUsage(resources_[index]);
+}
+
string16 TaskManagerModel::GetResourceCPUUsage(int index) const {
DCHECK(index < ResourceCount());
return WideToUTF16Hack(StringPrintf(
@@ -165,11 +175,15 @@
return GetMemCellText(phys_mem);
}
-string16 TaskManagerModel::GetResourceProcessId(int index) const {
+int TaskManagerModel::GetProcessId(int index) const {
DCHECK(index < ResourceCount());
- return base::IntToString16(base::GetProcId(resources_[index]->GetProcess()));
+ return base::GetProcId(resources_[index]->GetProcess());
}
+string16 TaskManagerModel::GetResourceProcessId(int index) const {
+ return base::IntToString16(GetProcessId(index));
+}
+
string16 TaskManagerModel::GetResourceGoatsTeleported(int index) const {
DCHECK(index < ResourceCount());
return base::FormatNumber(GetGoatsTeleported(index));
@@ -482,6 +496,12 @@
}
void TaskManagerModel::StartUpdating() {
+ // Multiple StartUpdating requests may come in, and we only need to take
+ // action the first time.
+ update_requests_++;
+ if (update_requests_ > 1)
+ return;
+ DCHECK_EQ(1, update_requests_);
DCHECK_NE(TASK_PENDING, update_state_);
// If update_state_ is STOPPING, it means a task is still pending. Setting
@@ -508,6 +528,12 @@
}
void TaskManagerModel::StopUpdating() {
+ // Don't actually stop updating until we have heard as many calls as those
+ // to StartUpdating.
+ update_requests_--;
+ if (update_requests_ > 0)
+ return;
+ DCHECK_EQ(0, update_requests_);
DCHECK_EQ(TASK_PENDING, update_state_);
update_state_ = STOPPING;
@@ -522,6 +548,9 @@
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &TaskManagerModel::UnregisterForJobDoneNotifications));
+
+ // Must clear the resources before the next attempt to start updating.
+ Clear();
}
void TaskManagerModel::AddResourceProvider(
@@ -925,7 +954,6 @@
void TaskManager::OnWindowClosed() {
model_->StopUpdating();
- model_->Clear();
}
// static
« no previous file with comments | « chrome/browser/task_manager/task_manager.h ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698