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

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

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications 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
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"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 host_->opening_channel_ = false; 235 host_->opening_channel_ = false;
236 host_->OnChannelError(); 236 host_->OnChannelError();
237 237
238 // This will delete host_, which will also destroy this! 238 // This will delete host_, which will also destroy this!
239 host_->OnChildDied(); 239 host_->OnChildDied();
240 } 240 }
241 241
242 242
243 ChildProcessHost::Iterator::Iterator() 243 ChildProcessHost::Iterator::Iterator()
244 : all_(true), type_(UNKNOWN_PROCESS) { 244 : all_(true), type_(UNKNOWN_PROCESS) {
245 DCHECK(MessageLoop::current() == 245 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
246 ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
247 "ChildProcessInfo::Iterator must be used on the IO thread."; 246 "ChildProcessInfo::Iterator must be used on the IO thread.";
248 iterator_ = Singleton<ChildProcessList>::get()->begin(); 247 iterator_ = Singleton<ChildProcessList>::get()->begin();
249 } 248 }
250 249
251 ChildProcessHost::Iterator::Iterator(ProcessType type) 250 ChildProcessHost::Iterator::Iterator(ProcessType type)
252 : all_(false), type_(type) { 251 : all_(false), type_(type) {
253 // IO loop can be NULL in unit tests. 252 // IO loop can be NULL in unit tests.
254 DCHECK(!ChromeThread::GetMessageLoop(ChromeThread::IO) || 253 DCHECK(!MessageLoop::current() ||
255 MessageLoop::current() == 254 ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
256 ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
257 "ChildProcessInfo::Iterator must be used on the IO thread."; 255 "ChildProcessInfo::Iterator must be used on the IO thread.";
258 iterator_ = Singleton<ChildProcessList>::get()->begin(); 256 iterator_ = Singleton<ChildProcessList>::get()->begin();
259 if (!Done() && (*iterator_)->type() != type_) 257 if (!Done() && (*iterator_)->type() != type_)
260 ++(*this); 258 ++(*this);
261 } 259 }
262 260
263 ChildProcessHost* ChildProcessHost::Iterator::operator++() { 261 ChildProcessHost* ChildProcessHost::Iterator::operator++() {
264 do { 262 do {
265 ++iterator_; 263 ++iterator_;
266 if (Done()) 264 if (Done())
267 break; 265 break;
268 266
269 if (!all_ && (*iterator_)->type() != type_) 267 if (!all_ && (*iterator_)->type() != type_)
270 continue; 268 continue;
271 269
272 return *iterator_; 270 return *iterator_;
273 } while (true); 271 } while (true);
274 272
275 return NULL; 273 return NULL;
276 } 274 }
277 275
278 bool ChildProcessHost::Iterator::Done() { 276 bool ChildProcessHost::Iterator::Done() {
279 return iterator_ == Singleton<ChildProcessList>::get()->end(); 277 return iterator_ == Singleton<ChildProcessList>::get()->end();
280 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698