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

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

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 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_ITERATOR_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_ITERATOR_H_
7 #pragma once
8
9 #include <list>
10
11 #include "content/common/content_export.h"
12 #include "content/public/common/process_type.h"
13
14 class BrowserChildProcessHost;
15
16 namespace IPC {
17 class Message;
18 }
19
20 namespace content {
21
22 class BrowserChildProcessHostDelegate;
23 struct ChildProcessData;
24
25 // This class allows iteration through either all child processes, or ones of a
26 // specific type, depending on which constructor is used. Note that this should
27 // be done from the IO thread and that the iterator should not be kept around as
28 // it may be invalidated on subsequent event processing in the event loop.
29 class CONTENT_EXPORT BrowserChildProcessHostIterator {
30 public:
31 BrowserChildProcessHostIterator();
32 explicit BrowserChildProcessHostIterator(content::ProcessType type);
33
34 // These methods work on the current iterator object. Only call them if
35 // Done() returns false.
36 bool operator++();
37 bool Done();
38 const ChildProcessData& GetData();
39 bool Send(IPC::Message* message);
40 BrowserChildProcessHostDelegate* GetDelegate();
41
42 private:
43 bool all_;
44 content::ProcessType type_;
45 std::list<BrowserChildProcessHost*>::iterator iterator_;
46 };
47
48 // Helper class so that subclasses of BrowserChildProcessHostDelegate can be
49 // iterated with no casting needing. Note that because of the components build,
50 // this class can only be used by BCPHD implementations that live in content,
51 // otherwise link errors will result.
52 template <class T>
53 class CONTENT_EXPORT BrowserChildProcessHostTypeIterator
54 : public BrowserChildProcessHostIterator {
55 public:
56 explicit BrowserChildProcessHostTypeIterator(content::ProcessType type)
57 : BrowserChildProcessHostIterator(type) {}
58 T* operator->() {
59 return static_cast<T*>(GetDelegate());
60 }
61 T* operator*() {
62 return static_cast<T*>(GetDelegate());
63 }
64 };
65
66 }; // namespace content
67
68 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_ITERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698