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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/public/browser/browser_child_process_host_iterator.cc
===================================================================
--- content/public/browser/browser_child_process_host_iterator.cc (revision 0)
+++ content/public/browser/browser_child_process_host_iterator.cc (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/browser/browser_child_process_host_iterator.h"
+
+#include "base/logging.h"
+#include "content/browser/browser_child_process_host.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+BrowserChildProcessHostIterator::BrowserChildProcessHostIterator()
+ : all_(true), type_(content::PROCESS_TYPE_UNKNOWN) {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
+ "BrowserChildProcessHostIterator must be used on the IO thread.";
+ iterator_ = ::BrowserChildProcessHost::GetIterator()->begin();
+}
+
+BrowserChildProcessHostIterator::BrowserChildProcessHostIterator(
+ content::ProcessType type)
+ : all_(false), type_(type) {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
+ "BrowserChildProcessHostIterator must be used on the IO thread.";
+ iterator_ = ::BrowserChildProcessHost::GetIterator()->begin();
+ if (!Done() && (*iterator_)->GetData().type != type_)
+ ++(*this);
+}
+
+bool BrowserChildProcessHostIterator::operator++() {
+ CHECK(!Done());
+ do {
+ ++iterator_;
+ if (Done())
+ break;
+
+ if (!all_ && (*iterator_)->GetData().type != type_)
+ continue;
+
+ return true;
+ } while (true);
+
+ return false;
+}
+
+bool BrowserChildProcessHostIterator::Done() {
+ return iterator_ == ::BrowserChildProcessHost::GetIterator()->end();
+}
+
+const ChildProcessData& BrowserChildProcessHostIterator::GetData() {
+ CHECK(!Done());
+ return (*iterator_)->GetData();
+}
+
+bool BrowserChildProcessHostIterator::Send(IPC::Message* message) {
+ CHECK(!Done());
+ return (*iterator_)->Send(message);
+}
+
+BrowserChildProcessHostDelegate*
+ BrowserChildProcessHostIterator::GetDelegate() {
+ return (*iterator_)->delegate();
+}
+
+} // namespace content
Property changes on: content\public\browser\browser_child_process_host_iterator.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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