OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "content/browser/child_process_launcher.h" | 11 #include "content/browser/child_process_launcher.h" |
12 #include "content/browser/renderer_host/resource_message_filter.h" | |
13 #include "content/common/child_process_host.h" | 12 #include "content/common/child_process_host.h" |
14 #include "content/common/child_process_info.h" | 13 #include "content/common/child_process_info.h" |
15 | 14 |
16 class ResourceDispatcherHost; | 15 class ResourceDispatcherHost; |
17 | 16 |
18 // Plugins/workers and other child processes that live on the IO thread should | 17 // Plugins/workers and other child processes that live on the IO thread should |
19 // derive from this class. | 18 // derive from this class. |
20 // | 19 // |
21 // [Browser]RenderProcessHost is the main exception that doesn't derive from | 20 // [Browser]RenderProcessHost is the main exception that doesn't derive from |
22 // this class. That project lives on the UI thread. | 21 // this class. That project lives on the UI thread. |
(...skipping 27 matching lines...) Expand all Loading... |
50 BrowserChildProcessHost* operator++(); | 49 BrowserChildProcessHost* operator++(); |
51 bool Done(); | 50 bool Done(); |
52 | 51 |
53 private: | 52 private: |
54 bool all_; | 53 bool all_; |
55 ChildProcessInfo::ProcessType type_; | 54 ChildProcessInfo::ProcessType type_; |
56 std::list<BrowserChildProcessHost*>::iterator iterator_; | 55 std::list<BrowserChildProcessHost*>::iterator iterator_; |
57 }; | 56 }; |
58 | 57 |
59 protected: | 58 protected: |
60 // |resource_dispatcher_host| may be NULL to indicate none is needed for | |
61 // this process type. | |
62 // |url_request_context_getter| allows derived classes to override the | |
63 // net::URLRequestContext. | |
64 BrowserChildProcessHost( | |
65 ChildProcessInfo::ProcessType type, | |
66 ResourceDispatcherHost* resource_dispatcher_host, | |
67 ResourceMessageFilter::URLRequestContextOverride* | |
68 url_request_context_override); | |
69 | |
70 // A convenient constructor for those classes that want to use the default | 59 // A convenient constructor for those classes that want to use the default |
71 // net::URLRequestContext. | 60 // net::URLRequestContext. |
72 BrowserChildProcessHost( | 61 BrowserChildProcessHost( |
73 ChildProcessInfo::ProcessType type, | 62 ChildProcessInfo::ProcessType type, |
74 ResourceDispatcherHost* resource_dispatcher_host); | 63 ResourceDispatcherHost* resource_dispatcher_host); |
75 | 64 |
76 // Derived classes call this to launch the child process asynchronously. | 65 // Derived classes call this to launch the child process asynchronously. |
77 void Launch( | 66 void Launch( |
78 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
79 const FilePath& exposed_dir, | 68 const FilePath& exposed_dir, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 virtual void Notify(NotificationType type); | 103 virtual void Notify(NotificationType type); |
115 // Extends the base class implementation and removes this host from | 104 // Extends the base class implementation and removes this host from |
116 // the host list. Calls ChildProcessHost::ForceShutdown | 105 // the host list. Calls ChildProcessHost::ForceShutdown |
117 virtual void ForceShutdown(); | 106 virtual void ForceShutdown(); |
118 | 107 |
119 ResourceDispatcherHost* resource_dispatcher_host() { | 108 ResourceDispatcherHost* resource_dispatcher_host() { |
120 return resource_dispatcher_host_; | 109 return resource_dispatcher_host_; |
121 } | 110 } |
122 | 111 |
123 private: | 112 private: |
124 void Initialize(ResourceMessageFilter::URLRequestContextOverride* | |
125 url_request_context_override); | |
126 | |
127 // By using an internal class as the ChildProcessLauncher::Client, we can | 113 // By using an internal class as the ChildProcessLauncher::Client, we can |
128 // intercept OnProcessLaunched and do our own processing before | 114 // intercept OnProcessLaunched and do our own processing before |
129 // calling the subclass' implementation. | 115 // calling the subclass' implementation. |
130 class ClientHook : public ChildProcessLauncher::Client { | 116 class ClientHook : public ChildProcessLauncher::Client { |
131 public: | 117 public: |
132 explicit ClientHook(BrowserChildProcessHost* host); | 118 explicit ClientHook(BrowserChildProcessHost* host); |
133 virtual void OnProcessLaunched(); | 119 virtual void OnProcessLaunched(); |
134 private: | 120 private: |
135 BrowserChildProcessHost* host_; | 121 BrowserChildProcessHost* host_; |
136 }; | 122 }; |
137 ClientHook client_; | 123 ClientHook client_; |
138 // May be NULL if this current process has no resource dispatcher host. | 124 // May be NULL if this current process has no resource dispatcher host. |
139 ResourceDispatcherHost* resource_dispatcher_host_; | 125 ResourceDispatcherHost* resource_dispatcher_host_; |
140 scoped_ptr<ChildProcessLauncher> child_process_; | 126 scoped_ptr<ChildProcessLauncher> child_process_; |
141 }; | 127 }; |
142 | 128 |
143 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 129 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
OLD | NEW |