OLD | NEW |
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 "content/public/browser/browser_child_process_host_iterator.h" | 5 #include "content/public/browser/browser_child_process_host_iterator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/browser_child_process_host.h" | 8 #include "content/browser/browser_child_process_host_impl.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator() | 13 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator() |
14 : all_(true), type_(content::PROCESS_TYPE_UNKNOWN) { | 14 : all_(true), type_(content::PROCESS_TYPE_UNKNOWN) { |
15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << | 15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << |
16 "BrowserChildProcessHostIterator must be used on the IO thread."; | 16 "BrowserChildProcessHostIterator must be used on the IO thread."; |
17 iterator_ = ::BrowserChildProcessHost::GetIterator()->begin(); | 17 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin(); |
18 } | 18 } |
19 | 19 |
20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator( | 20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator( |
21 content::ProcessType type) | 21 content::ProcessType type) |
22 : all_(false), type_(type) { | 22 : all_(false), type_(type) { |
23 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << | 23 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << |
24 "BrowserChildProcessHostIterator must be used on the IO thread."; | 24 "BrowserChildProcessHostIterator must be used on the IO thread."; |
25 iterator_ = ::BrowserChildProcessHost::GetIterator()->begin(); | 25 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin(); |
26 if (!Done() && (*iterator_)->GetData().type != type_) | 26 if (!Done() && (*iterator_)->GetData().type != type_) |
27 ++(*this); | 27 ++(*this); |
28 } | 28 } |
29 | 29 |
30 bool BrowserChildProcessHostIterator::operator++() { | 30 bool BrowserChildProcessHostIterator::operator++() { |
31 CHECK(!Done()); | 31 CHECK(!Done()); |
32 do { | 32 do { |
33 ++iterator_; | 33 ++iterator_; |
34 if (Done()) | 34 if (Done()) |
35 break; | 35 break; |
36 | 36 |
37 if (!all_ && (*iterator_)->GetData().type != type_) | 37 if (!all_ && (*iterator_)->GetData().type != type_) |
38 continue; | 38 continue; |
39 | 39 |
40 return true; | 40 return true; |
41 } while (true); | 41 } while (true); |
42 | 42 |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
46 bool BrowserChildProcessHostIterator::Done() { | 46 bool BrowserChildProcessHostIterator::Done() { |
47 return iterator_ == ::BrowserChildProcessHost::GetIterator()->end(); | 47 return iterator_ == BrowserChildProcessHostImpl::GetIterator()->end(); |
48 } | 48 } |
49 | 49 |
50 const ChildProcessData& BrowserChildProcessHostIterator::GetData() { | 50 const ChildProcessData& BrowserChildProcessHostIterator::GetData() { |
51 CHECK(!Done()); | 51 CHECK(!Done()); |
52 return (*iterator_)->GetData(); | 52 return (*iterator_)->GetData(); |
53 } | 53 } |
54 | 54 |
55 bool BrowserChildProcessHostIterator::Send(IPC::Message* message) { | 55 bool BrowserChildProcessHostIterator::Send(IPC::Message* message) { |
56 CHECK(!Done()); | 56 CHECK(!Done()); |
57 return (*iterator_)->Send(message); | 57 return (*iterator_)->Send(message); |
58 } | 58 } |
59 | 59 |
60 BrowserChildProcessHostDelegate* | 60 BrowserChildProcessHostDelegate* |
61 BrowserChildProcessHostIterator::GetDelegate() { | 61 BrowserChildProcessHostIterator::GetDelegate() { |
62 return (*iterator_)->delegate(); | 62 return (*iterator_)->delegate(); |
63 } | 63 } |
64 | 64 |
65 } // namespace content | 65 } // namespace content |
OLD | NEW |