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

Side by Side Diff: content/public/browser/browser_child_process_host_iterator.cc

Issue 9150017: Add a Content API around BrowserChildProcessHost, similar to what was done with ChildProcessHost.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix?! Created 8 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/browser_child_process_host_iterator.h"
6
7 #include "base/logging.h"
8 #include "content/browser/browser_child_process_host.h"
9 #include "content/public/browser/browser_thread.h"
10
11 namespace content {
12
13 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator()
14 : all_(true), type_(content::PROCESS_TYPE_UNKNOWN) {
15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
16 "BrowserChildProcessHostIterator must be used on the IO thread.";
17 iterator_ = ::BrowserChildProcessHost::GetIterator()->begin();
18 }
19
20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator(
21 content::ProcessType type)
22 : all_(false), type_(type) {
23 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
24 "BrowserChildProcessHostIterator must be used on the IO thread.";
25 iterator_ = ::BrowserChildProcessHost::GetIterator()->begin();
26 if (!Done() && (*iterator_)->GetData().type != type_)
27 ++(*this);
28 }
29
30 bool BrowserChildProcessHostIterator::operator++() {
31 CHECK(!Done());
32 do {
33 ++iterator_;
34 if (Done())
35 break;
36
37 if (!all_ && (*iterator_)->GetData().type != type_)
38 continue;
39
40 return true;
41 } while (true);
42
43 return false;
44 }
45
46 bool BrowserChildProcessHostIterator::Done() {
47 return iterator_ == ::BrowserChildProcessHost::GetIterator()->end();
48 }
49
50 const ChildProcessData& BrowserChildProcessHostIterator::GetData() {
51 CHECK(!Done());
52 return (*iterator_)->GetData();
53 }
54
55 bool BrowserChildProcessHostIterator::Send(IPC::Message* message) {
56 CHECK(!Done());
57 return (*iterator_)->Send(message);
58 }
59
60 BrowserChildProcessHostDelegate*
61 BrowserChildProcessHostIterator::GetDelegate() {
62 return (*iterator_)->delegate();
63 }
64
65 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/browser_child_process_host_iterator.h ('k') | content/public/common/child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698