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

Side by Side Diff: chrome/browser/extensions/extension_processes_api.cc

Issue 10169022: ifdef'd out more references to TaskManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_processes_api.h" 5 #include "chrome/browser/extensions/extension_processes_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 28 matching lines...) Expand all
39 result->SetDouble(keys::kPrivateMemoryKey, static_cast<double>(pr_mem)); 39 result->SetDouble(keys::kPrivateMemoryKey, static_cast<double>(pr_mem));
40 result->SetDouble(keys::kSharedMemoryKey, static_cast<double>(sh_mem)); 40 result->SetDouble(keys::kSharedMemoryKey, static_cast<double>(sh_mem));
41 return result; 41 return result;
42 } 42 }
43 43
44 ExtensionProcessesEventRouter* ExtensionProcessesEventRouter::GetInstance() { 44 ExtensionProcessesEventRouter* ExtensionProcessesEventRouter::GetInstance() {
45 return Singleton<ExtensionProcessesEventRouter>::get(); 45 return Singleton<ExtensionProcessesEventRouter>::get();
46 } 46 }
47 47
48 ExtensionProcessesEventRouter::ExtensionProcessesEventRouter() { 48 ExtensionProcessesEventRouter::ExtensionProcessesEventRouter() {
49 #if defined(ENABLE_TASK_MANAGER)
49 model_ = TaskManager::GetInstance()->model(); 50 model_ = TaskManager::GetInstance()->model();
50 model_->AddObserver(this); 51 model_->AddObserver(this);
52 #endif // defined(ENABLE_TASK_MANAGER)
51 } 53 }
52 54
53 ExtensionProcessesEventRouter::~ExtensionProcessesEventRouter() { 55 ExtensionProcessesEventRouter::~ExtensionProcessesEventRouter() {
56 #if defined(ENABLE_TASK_MANAGER)
54 model_->RemoveObserver(this); 57 model_->RemoveObserver(this);
58 #endif // defined(ENABLE_TASK_MANAGER)
55 } 59 }
56 60
57 void ExtensionProcessesEventRouter::ObserveProfile(Profile* profile) { 61 void ExtensionProcessesEventRouter::ObserveProfile(Profile* profile) {
58 profiles_.insert(profile); 62 profiles_.insert(profile);
59 } 63 }
60 64
61 void ExtensionProcessesEventRouter::ListenerAdded() { 65 void ExtensionProcessesEventRouter::ListenerAdded() {
66 #if defined(ENABLE_TASK_MANAGER)
62 model_->StartUpdating(); 67 model_->StartUpdating();
68 #endif // defined(ENABLE_TASK_MANAGER)
63 } 69 }
64 70
65 void ExtensionProcessesEventRouter::ListenerRemoved() { 71 void ExtensionProcessesEventRouter::ListenerRemoved() {
72 #if defined(ENABLE_TASK_MANAGER)
66 model_->StopUpdating(); 73 model_->StopUpdating();
74 #endif // defined(ENABLE_TASK_MANAGER)
67 } 75 }
68 76
69 void ExtensionProcessesEventRouter::OnItemsChanged(int start, int length) { 77 void ExtensionProcessesEventRouter::OnItemsChanged(int start, int length) {
78 #if defined(ENABLE_TASK_MANAGER)
70 if (model_) { 79 if (model_) {
71 ListValue args; 80 ListValue args;
72 DictionaryValue* processes = new DictionaryValue(); 81 DictionaryValue* processes = new DictionaryValue();
73 for (int i = start; i < start + length; i++) { 82 for (int i = start; i < start + length; i++) {
74 if (model_->IsResourceFirstInGroup(i)) { 83 if (model_->IsResourceFirstInGroup(i)) {
75 int id = model_->GetProcessId(i); 84 int id = model_->GetProcessId(i);
76 85
77 // Determine process type 86 // Determine process type
78 std::string type = keys::kProcessTypeOther; 87 std::string type = keys::kProcessTypeOther;
79 TaskManager::Resource::Type resource_type = model_->GetResourceType(i); 88 TaskManager::Resource::Type resource_type = model_->GetResourceType(i);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 std::string json_args; 146 std::string json_args;
138 base::JSONWriter::Write(&args, &json_args); 147 base::JSONWriter::Write(&args, &json_args);
139 148
140 // Notify each profile that is interested. 149 // Notify each profile that is interested.
141 for (ProfileSet::iterator it = profiles_.begin(); 150 for (ProfileSet::iterator it = profiles_.begin();
142 it != profiles_.end(); it++) { 151 it != profiles_.end(); it++) {
143 Profile* profile = *it; 152 Profile* profile = *it;
144 DispatchEvent(profile, keys::kOnUpdated, json_args); 153 DispatchEvent(profile, keys::kOnUpdated, json_args);
145 } 154 }
146 } 155 }
156 #endif // defined(ENABLE_TASK_MANAGER)
147 } 157 }
148 158
149 void ExtensionProcessesEventRouter::DispatchEvent(Profile* profile, 159 void ExtensionProcessesEventRouter::DispatchEvent(Profile* profile,
150 const char* event_name, 160 const char* event_name,
151 const std::string& json_args) { 161 const std::string& json_args) {
152 if (profile && profile->GetExtensionEventRouter()) { 162 if (profile && profile->GetExtensionEventRouter()) {
153 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 163 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
154 event_name, json_args, NULL, GURL()); 164 event_name, json_args, NULL, GURL());
155 } 165 }
156 } 166 }
(...skipping 11 matching lines...) Expand all
168 base::IntToString(tab_id)); 178 base::IntToString(tab_id));
169 return false; 179 return false;
170 } 180 }
171 181
172 // Return the process ID of the tab as an integer. 182 // Return the process ID of the tab as an integer.
173 int id = base::GetProcId(contents->web_contents()-> 183 int id = base::GetProcId(contents->web_contents()->
174 GetRenderProcessHost()->GetHandle()); 184 GetRenderProcessHost()->GetHandle());
175 result_.reset(Value::CreateIntegerValue(id)); 185 result_.reset(Value::CreateIntegerValue(id));
176 return true; 186 return true;
177 } 187 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698