| OLD | NEW |
| 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_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 | 12 |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
| 16 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
| 17 #include "base/supports_user_data.h" | 17 #include "base/supports_user_data.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/public/browser/owned_interface.h" | |
| 20 #include "ipc/ipc_channel_proxy.h" | 19 #include "ipc/ipc_channel_proxy.h" |
| 21 #include "ipc/ipc_sender.h" | 20 #include "ipc/ipc_sender.h" |
| 22 #include "services/shell/public/cpp/interface_registry.h" | 21 #include "services/shell/public/cpp/interface_registry.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
| 24 | 23 |
| 25 class GURL; | 24 class GURL; |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class SharedPersistentMemoryAllocator; | 27 class SharedPersistentMemoryAllocator; |
| 29 class TimeDelta; | 28 class TimeDelta; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace media { | 31 namespace media { |
| 33 class AudioOutputController; | 32 class AudioOutputController; |
| 34 class MediaKeys; | 33 class MediaKeys; |
| 35 } | 34 } |
| 36 | 35 |
| 37 namespace shell { | 36 namespace shell { |
| 38 class Connection; | 37 class Connection; |
| 39 class InterfaceProvider; | 38 class InterfaceProvider; |
| 40 } | 39 } |
| 41 | 40 |
| 42 namespace content { | 41 namespace content { |
| 43 class BrowserContext; | 42 class BrowserContext; |
| 44 class BrowserMessageFilter; | 43 class BrowserMessageFilter; |
| 45 class OwnedInterface; | |
| 46 class RenderProcessHostObserver; | 44 class RenderProcessHostObserver; |
| 47 class RenderWidgetHost; | 45 class RenderWidgetHost; |
| 48 class StoragePartition; | 46 class StoragePartition; |
| 49 struct GlobalRequestID; | 47 struct GlobalRequestID; |
| 50 | 48 |
| 51 // Interface that represents the browser side of the browser <-> renderer | 49 // Interface that represents the browser side of the browser <-> renderer |
| 52 // communication channel. There will generally be one RenderProcessHost per | 50 // communication channel. There will generally be one RenderProcessHost per |
| 53 // renderer process. | 51 // renderer process. |
| 54 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, | 52 class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, |
| 55 public IPC::Listener, | 53 public IPC::Listener, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Call this to allow queueing of IPC messages that are sent before the | 176 // Call this to allow queueing of IPC messages that are sent before the |
| 179 // process is launched. | 177 // process is launched. |
| 180 virtual void EnableSendQueue() = 0; | 178 virtual void EnableSendQueue() = 0; |
| 181 | 179 |
| 182 // Returns the renderer channel. | 180 // Returns the renderer channel. |
| 183 virtual IPC::ChannelProxy* GetChannel() = 0; | 181 virtual IPC::ChannelProxy* GetChannel() = 0; |
| 184 | 182 |
| 185 // Adds a message filter to the IPC channel. | 183 // Adds a message filter to the IPC channel. |
| 186 virtual void AddFilter(BrowserMessageFilter* filter) = 0; | 184 virtual void AddFilter(BrowserMessageFilter* filter) = 0; |
| 187 | 185 |
| 188 // Adds an interface impl which will be owned by this host and registered in | |
| 189 // its interface registry. Requests to bind will be handled by calling | |
| 190 // |callback|, which must be a member function on |impl|. The method referred | |
| 191 // to by |Callback| must conform to the signature `void fun(MyInterfaceRequest | |
| 192 // request)`. | |
| 193 // | |
| 194 // New connections and incoming messages will be dispatched on |task_runner| | |
| 195 // (or on the current task runner if not specified). The impl will also be | |
| 196 // deleted on |task_runner|. | |
| 197 template <typename InterfaceImpl, typename Callback> | |
| 198 void AddOwnedInterface(std::unique_ptr<InterfaceImpl> impl, | |
| 199 Callback callback, | |
| 200 const scoped_refptr<base::SingleThreadTaskRunner>& | |
| 201 task_runner = nullptr) { | |
| 202 auto owned = base::MakeUnique<content::OwnedInterfaceImpl<InterfaceImpl>>( | |
| 203 std::move(impl), task_runner); | |
| 204 GetInterfaceRegistry()->AddInterface( | |
| 205 base::Bind(callback, base::Unretained(owned->get())), task_runner); | |
| 206 AddOwnedInterface(std::move(owned)); | |
| 207 } | |
| 208 | |
| 209 // Adds the |impl| to the collection of interface impls owned by this | |
| 210 // host. The impl must be registered separately using | |
| 211 // |GetInterfaceRegistry()|. This function is useful if a single object is | |
| 212 // used to implement several interfaces. | |
| 213 // | |
| 214 // Implementation of |AddOwnedInterface()| must guarantee that the added impls | |
| 215 // outlive the |InterfaceRegistry| returned by |GetInterfaceRegistry()|. | |
| 216 virtual void AddOwnedInterface(std::unique_ptr<OwnedInterface> impl) = 0; | |
| 217 | |
| 218 // Try to shutdown the associated render process as fast as possible | 186 // Try to shutdown the associated render process as fast as possible |
| 219 virtual bool FastShutdownForPageCount(size_t count) = 0; | 187 virtual bool FastShutdownForPageCount(size_t count) = 0; |
| 220 | 188 |
| 221 // TODO(ananta) | 189 // TODO(ananta) |
| 222 // Revisit whether the virtual functions declared from here on need to be | 190 // Revisit whether the virtual functions declared from here on need to be |
| 223 // part of the interface. | 191 // part of the interface. |
| 224 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | 192 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; |
| 225 virtual bool IgnoreInputEvents() const = 0; | 193 virtual bool IgnoreInputEvents() const = 0; |
| 226 | 194 |
| 227 // Schedules the host for deletion and removes it from the all_hosts list. | 195 // Schedules the host for deletion and removes it from the all_hosts list. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 static void SetMaxRendererProcessCount(size_t count); | 369 static void SetMaxRendererProcessCount(size_t count); |
| 402 | 370 |
| 403 // Returns the current maximum number of renderer process hosts kept by the | 371 // Returns the current maximum number of renderer process hosts kept by the |
| 404 // content module. | 372 // content module. |
| 405 static size_t GetMaxRendererProcessCount(); | 373 static size_t GetMaxRendererProcessCount(); |
| 406 }; | 374 }; |
| 407 | 375 |
| 408 } // namespace content. | 376 } // namespace content. |
| 409 | 377 |
| 410 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | 378 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ |
| OLD | NEW |