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

Side by Side Diff: chrome/common/child_process_host.cc

Issue 353015: Last patch in removing MessageLoop* caching. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/utility_process_host_unittest.cc ('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/common/child_process_host.h" 5 #include "chrome/common/child_process_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "base/process_util.h" 12 #include "base/process_util.h"
14 #include "base/singleton.h" 13 #include "base/singleton.h"
15 #include "base/string_util.h" 14 #include "base/string_util.h"
16 #include "base/waitable_event.h" 15 #include "base/waitable_event.h"
17 #include "chrome/browser/chrome_thread.h" 16 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths_internal.h" 18 #include "chrome/common/chrome_paths_internal.h"
20 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/notification_service.h" 20 #include "chrome/common/notification_service.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 144
146 bool ChildProcessHost::Send(IPC::Message* msg) { 145 bool ChildProcessHost::Send(IPC::Message* msg) {
147 if (!channel_.get()) { 146 if (!channel_.get()) {
148 delete msg; 147 delete msg;
149 return false; 148 return false;
150 } 149 }
151 return channel_->Send(msg); 150 return channel_->Send(msg);
152 } 151 }
153 152
154 void ChildProcessHost::Notify(NotificationType type) { 153 void ChildProcessHost::Notify(NotificationType type) {
155 resource_dispatcher_host_->ui_loop()->PostTask( 154 ChromeThread::PostTask(
156 FROM_HERE, new ChildNotificationTask(type, this)); 155 ChromeThread::UI, FROM_HERE, new ChildNotificationTask(type, this));
157 } 156 }
158 157
159 void ChildProcessHost::OnChildDied() { 158 void ChildProcessHost::OnChildDied() {
160 DCHECK(handle()); 159 DCHECK(handle());
161 160
162 bool did_crash = base::DidProcessCrash(NULL, handle()); 161 bool did_crash = base::DidProcessCrash(NULL, handle());
163 if (did_crash) { 162 if (did_crash) {
164 // Report that this child process crashed. 163 // Report that this child process crashed.
165 Notify(NotificationType::CHILD_PROCESS_CRASHED); 164 Notify(NotificationType::CHILD_PROCESS_CRASHED);
166 } 165 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 241
243 ChildProcessHost::Iterator::Iterator() 242 ChildProcessHost::Iterator::Iterator()
244 : all_(true), type_(UNKNOWN_PROCESS) { 243 : all_(true), type_(UNKNOWN_PROCESS) {
245 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) << 244 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
246 "ChildProcessInfo::Iterator must be used on the IO thread."; 245 "ChildProcessInfo::Iterator must be used on the IO thread.";
247 iterator_ = Singleton<ChildProcessList>::get()->begin(); 246 iterator_ = Singleton<ChildProcessList>::get()->begin();
248 } 247 }
249 248
250 ChildProcessHost::Iterator::Iterator(ProcessType type) 249 ChildProcessHost::Iterator::Iterator(ProcessType type)
251 : all_(false), type_(type) { 250 : all_(false), type_(type) {
252 // IO loop can be NULL in unit tests. 251 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
253 DCHECK(!MessageLoop::current() ||
254 ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
255 "ChildProcessInfo::Iterator must be used on the IO thread."; 252 "ChildProcessInfo::Iterator must be used on the IO thread.";
256 iterator_ = Singleton<ChildProcessList>::get()->begin(); 253 iterator_ = Singleton<ChildProcessList>::get()->begin();
257 if (!Done() && (*iterator_)->type() != type_) 254 if (!Done() && (*iterator_)->type() != type_)
258 ++(*this); 255 ++(*this);
259 } 256 }
260 257
261 ChildProcessHost* ChildProcessHost::Iterator::operator++() { 258 ChildProcessHost* ChildProcessHost::Iterator::operator++() {
262 do { 259 do {
263 ++iterator_; 260 ++iterator_;
264 if (Done()) 261 if (Done())
265 break; 262 break;
266 263
267 if (!all_ && (*iterator_)->type() != type_) 264 if (!all_ && (*iterator_)->type() != type_)
268 continue; 265 continue;
269 266
270 return *iterator_; 267 return *iterator_;
271 } while (true); 268 } while (true);
272 269
273 return NULL; 270 return NULL;
274 } 271 }
275 272
276 bool ChildProcessHost::Iterator::Done() { 273 bool ChildProcessHost::Iterator::Done() {
277 return iterator_ == Singleton<ChildProcessList>::get()->end(); 274 return iterator_ == Singleton<ChildProcessList>::get()->end();
278 } 275 }
OLDNEW
« no previous file with comments | « chrome/browser/utility_process_host_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698