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

Side by Side Diff: content/browser/browser_child_process_host_impl.h

Issue 12212089: content: convert child process notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: private Created 7 years, 9 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
OLDNEW
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 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/process.h" 12 #include "base/process.h"
13 #include "content/browser/child_process_launcher.h" 13 #include "content/browser/child_process_launcher.h"
14 #include "content/public/browser/browser_child_process_host.h" 14 #include "content/public/browser/browser_child_process_host.h"
15 #include "content/public/browser/child_process_data.h" 15 #include "content/public/browser/child_process_data.h"
16 #include "content/public/common/child_process_host_delegate.h" 16 #include "content/public/common/child_process_host_delegate.h"
17 17
18 namespace content { 18 namespace content {
19
19 class BrowserChildProcessHostIterator; 20 class BrowserChildProcessHostIterator;
21 class BrowserChildProcessObserver;
20 22
21 // Plugins/workers and other child processes that live on the IO thread use this 23 // Plugins/workers and other child processes that live on the IO thread use this
22 // class. RenderProcessHostImpl is the main exception that doesn't use this 24 // class. RenderProcessHostImpl is the main exception that doesn't use this
23 /// class because it lives on the UI thread. 25 /// class because it lives on the UI thread.
24 class CONTENT_EXPORT BrowserChildProcessHostImpl 26 class CONTENT_EXPORT BrowserChildProcessHostImpl
25 : public BrowserChildProcessHost, 27 : public BrowserChildProcessHost,
26 public NON_EXPORTED_BASE(ChildProcessHostDelegate), 28 public NON_EXPORTED_BASE(ChildProcessHostDelegate),
27 public ChildProcessLauncher::Client { 29 public ChildProcessLauncher::Client {
28 public: 30 public:
29 BrowserChildProcessHostImpl( 31 BrowserChildProcessHostImpl(
(...skipping 25 matching lines...) Expand all
55 // OnProcessLaunched is called or it will be invalid and may crash. 57 // OnProcessLaunched is called or it will be invalid and may crash.
56 base::ProcessHandle GetHandle() const; 58 base::ProcessHandle GetHandle() const;
57 59
58 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown 60 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown
59 void ForceShutdown(); 61 void ForceShutdown();
60 62
61 // Controls whether the child process should be terminated on browser 63 // Controls whether the child process should be terminated on browser
62 // shutdown. Default is to always terminate. 64 // shutdown. Default is to always terminate.
63 void SetTerminateChildOnShutdown(bool terminate_on_shutdown); 65 void SetTerminateChildOnShutdown(bool terminate_on_shutdown);
64 66
65 // Sends the given notification on the UI thread. 67 // Called when an instance of a particular child is created in a page.
66 void Notify(int type); 68 static void NotifyProcessInstanceCreated(const ChildProcessData& data);
67 69
68 BrowserChildProcessHostDelegate* delegate() const { return delegate_; 70 BrowserChildProcessHostDelegate* delegate() const { return delegate_; }
69 }
70 71
71 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; 72 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList;
72 private: 73 private:
73 friend class BrowserChildProcessHostIterator; 74 friend class BrowserChildProcessHostIterator;
75 friend class BrowserChildProcessObserver;
74 76
75 static BrowserChildProcessList* GetIterator(); 77 static BrowserChildProcessList* GetIterator();
76 78
79 static void AddObserver(BrowserChildProcessObserver* observer);
80 static void RemoveObserver(BrowserChildProcessObserver* observer);
81
77 // ChildProcessHostDelegate implementation: 82 // ChildProcessHostDelegate implementation:
78 virtual bool CanShutdown() OVERRIDE; 83 virtual bool CanShutdown() OVERRIDE;
79 virtual void OnChildDisconnected() OVERRIDE; 84 virtual void OnChildDisconnected() OVERRIDE;
80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
81 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 86 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
82 virtual void OnChannelError() OVERRIDE; 87 virtual void OnChannelError() OVERRIDE;
83 88
84 // ChildProcessLauncher::Client implementation. 89 // ChildProcessLauncher::Client implementation.
85 virtual void OnProcessLaunched() OVERRIDE; 90 virtual void OnProcessLaunched() OVERRIDE;
86 91
87 ChildProcessData data_; 92 ChildProcessData data_;
88 BrowserChildProcessHostDelegate* delegate_; 93 BrowserChildProcessHostDelegate* delegate_;
89 scoped_ptr<ChildProcessHost> child_process_host_; 94 scoped_ptr<ChildProcessHost> child_process_host_;
90 95
91 scoped_ptr<ChildProcessLauncher> child_process_; 96 scoped_ptr<ChildProcessLauncher> child_process_;
92 }; 97 };
93 98
94 } // namespace content 99 } // namespace content
95 100
96 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ 101 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698