| 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_impl.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), process_type_(PROCESS_TYPE_UNKNOWN) { | 14 : all_(true), process_type_(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_ = BrowserChildProcessHostImpl::GetIterator()->begin(); | 17 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator(int type) | 20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator(int type) |
| 21 : all_(false), process_type_(type) { | 21 : all_(false), process_type_(type) { |
| 22 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << | 22 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << |
| 23 "BrowserChildProcessHostIterator must be used on the IO thread."; | 23 "BrowserChildProcessHostIterator must be used on the IO thread."; |
| 24 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin(); | 24 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin(); |
| 25 if (!Done() && (*iterator_)->GetData().process_type != process_type_) | 25 if (!Done() && (*iterator_)->GetData().process_type != process_type_) |
| 26 ++(*this); | 26 ++(*this); |
| 27 } | 27 } |
| 28 | 28 |
| 29 BrowserChildProcessHostIterator::~BrowserChildProcessHostIterator() { |
| 30 } |
| 31 |
| 29 bool BrowserChildProcessHostIterator::operator++() { | 32 bool BrowserChildProcessHostIterator::operator++() { |
| 30 CHECK(!Done()); | 33 CHECK(!Done()); |
| 31 do { | 34 do { |
| 32 ++iterator_; | 35 ++iterator_; |
| 33 if (Done()) | 36 if (Done()) |
| 34 break; | 37 break; |
| 35 | 38 |
| 36 if (!all_ && (*iterator_)->GetData().process_type != process_type_) | 39 if (!all_ && (*iterator_)->GetData().process_type != process_type_) |
| 37 continue; | 40 continue; |
| 38 | 41 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 CHECK(!Done()); | 58 CHECK(!Done()); |
| 56 return (*iterator_)->Send(message); | 59 return (*iterator_)->Send(message); |
| 57 } | 60 } |
| 58 | 61 |
| 59 BrowserChildProcessHostDelegate* | 62 BrowserChildProcessHostDelegate* |
| 60 BrowserChildProcessHostIterator::GetDelegate() { | 63 BrowserChildProcessHostIterator::GetDelegate() { |
| 61 return (*iterator_)->delegate(); | 64 return (*iterator_)->delegate(); |
| 62 } | 65 } |
| 63 | 66 |
| 64 } // namespace content | 67 } // namespace content |
| OLD | NEW |