Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / browser / browser_child_process_host_iterator.cc
bloba2aa0473b6f373d1f918ade89ded861a6f4eebdc
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.
5 #include "content/public/browser/browser_child_process_host_iterator.h"
7 #include "base/logging.h"
8 #include "content/browser/browser_child_process_host_impl.h"
9 #include "content/public/browser/browser_thread.h"
11 namespace content {
13 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator()
14 : all_(true), process_type_(PROCESS_TYPE_UNKNOWN) {
15 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
16 "BrowserChildProcessHostIterator must be used on the IO thread.";
17 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin();
20 BrowserChildProcessHostIterator::BrowserChildProcessHostIterator(int type)
21 : all_(false), process_type_(type) {
22 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
23 "BrowserChildProcessHostIterator must be used on the IO thread.";
24 DCHECK_NE(PROCESS_TYPE_RENDERER, type) <<
25 "BrowserChildProcessHostIterator doesn't work for renderer processes; "
26 "try RenderProcessHost::AllHostsIterator() instead.";
27 iterator_ = BrowserChildProcessHostImpl::GetIterator()->begin();
28 if (!Done() && (*iterator_)->GetData().process_type != process_type_)
29 ++(*this);
32 BrowserChildProcessHostIterator::~BrowserChildProcessHostIterator() {
35 bool BrowserChildProcessHostIterator::operator++() {
36 CHECK(!Done());
37 do {
38 ++iterator_;
39 if (Done())
40 break;
42 if (!all_ && (*iterator_)->GetData().process_type != process_type_)
43 continue;
45 return true;
46 } while (true);
48 return false;
51 bool BrowserChildProcessHostIterator::Done() {
52 return iterator_ == BrowserChildProcessHostImpl::GetIterator()->end();
55 const ChildProcessData& BrowserChildProcessHostIterator::GetData() {
56 CHECK(!Done());
57 return (*iterator_)->GetData();
60 bool BrowserChildProcessHostIterator::Send(IPC::Message* message) {
61 CHECK(!Done());
62 return (*iterator_)->Send(message);
65 BrowserChildProcessHostDelegate*
66 BrowserChildProcessHostIterator::GetDelegate() {
67 return (*iterator_)->delegate();
70 } // namespace content