Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | |
| 6 #define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/id_map.h" | |
| 10 #include "base/process.h" | |
|
jam
2011/11/11 03:24:29
is this really needed?
ananta
2011/11/16 19:47:14
Needed for typedefs like ProcessHandle, etc used b
| |
| 11 #include "base/process_util.h" | |
|
jam
2011/11/11 03:24:29
not needed?
ananta
2011/11/16 19:47:14
We use the TerminationStatus enum defined in this
| |
| 12 #include "base/time.h" | |
|
jam
2011/11/11 03:24:29
forward declare?
ananta
2011/11/16 19:47:14
Done.
| |
| 13 #include "content/common/content_export.h" | |
| 14 #include "ipc/ipc_channel_proxy.h" | |
|
jam
2011/11/11 03:24:29
nit: not needed
ananta
2011/11/16 19:47:14
Replaced with ipc_message.h to get the definition
| |
| 15 #include "ui/gfx/native_widget_types.h" | |
| 16 | |
| 17 class GURL; | |
| 18 struct ViewMsg_SwapOut_Params; | |
| 19 | |
| 20 namespace content { | |
| 21 class BrowserContext; | |
| 22 } | |
| 23 | |
| 24 // Virtual interface that represents the browser side of the browser <-> | |
|
jam
2011/11/11 03:24:29
nit: "virtual interface" is redundant (sorry I kno
ananta
2011/11/16 19:47:14
Done.
| |
| 25 // renderer communication channel. There will generally be one | |
| 26 // RenderProcessHost per renderer process. | |
| 27 class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender { | |
| 28 public: | |
| 29 typedef IDMap<RenderProcessHost>::iterator iterator; | |
| 30 // Details for RENDERER_PROCESS_CLOSED notifications. | |
| 31 struct RendererClosedDetails { | |
| 32 RendererClosedDetails(base::ProcessHandle handle, | |
| 33 base::TerminationStatus status, | |
| 34 int exit_code, | |
| 35 bool was_alive) { | |
| 36 this->handle = handle; | |
| 37 this->status = status; | |
| 38 this->exit_code = exit_code; | |
| 39 this->was_alive = was_alive; | |
| 40 } | |
| 41 base::ProcessHandle handle; | |
| 42 base::TerminationStatus status; | |
| 43 int exit_code; | |
| 44 bool was_alive; | |
| 45 }; | |
| 46 | |
| 47 RenderProcessHost() {} | |
|
jam
2011/11/11 03:24:29
nit: not needed
ananta
2011/11/16 19:47:14
Done.
| |
| 48 virtual ~RenderProcessHost() {} | |
| 49 | |
| 50 // Returns true iff channel_ has been set to non-NULL. Use this for checking | |
| 51 // if there is connection or not. Virtual for mocking out for tests. | |
| 52 virtual bool HasConnection() const = 0; | |
| 53 | |
| 54 // Call this to allow queueing of IPC messages that are sent before the | |
| 55 // process is launched. | |
| 56 virtual void EnableSendQueue() = 0; | |
|
jam
2011/11/11 03:24:29
no one calls this in chrome. why does it need to b
| |
| 57 | |
| 58 // Initialize the new renderer process, returning true on success. This must | |
| 59 // be called once before the object can be used, but can be called after | |
| 60 // that with no effect. Therefore, if the caller isn't sure about whether | |
| 61 // the process has been created, it should just call Init(). | |
| 62 virtual bool Init(bool is_accessibility_enabled) = 0; | |
| 63 | |
| 64 // Gets the next available routing id. | |
| 65 virtual int GetNextRoutingID() = 0; | |
| 66 | |
| 67 // Called on the UI thread to cancel any outstanding resource requests for | |
|
jam
2011/11/11 03:24:29
nit: we should get rid of all the "Called on UI th
ananta
2011/11/16 19:47:14
Done.
| |
| 68 // the specified render widget. | |
| 69 virtual void CancelResourceRequests(int render_widget_id) = 0; | |
|
jam
2011/11/11 03:24:29
no one calls this in chrome. why does it need to b
| |
| 70 | |
| 71 // Called on the UI thread to simulate a SwapOut_ACK message to the | |
| 72 // ResourceDispatcherHost. Necessary for a cross-site request, in the case | |
| 73 // that the original RenderViewHost is not live and thus cannot run an | |
| 74 // unload handler. | |
| 75 virtual void CrossSiteSwapOutACK( | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 76 const ViewMsg_SwapOut_Params& params) = 0; | |
| 77 | |
| 78 // Called on the UI thread to wait for the next UpdateRect message for the | |
| 79 // specified render widget. Returns true if successful, and the msg out- | |
| 80 // param will contain a copy of the received UpdateRect message. | |
| 81 virtual bool WaitForUpdateMsg(int render_widget_id, | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 82 const base::TimeDelta& max_delay, | |
| 83 IPC::Message* msg) = 0; | |
| 84 | |
| 85 // Called when a received message cannot be decoded. | |
| 86 virtual void ReceivedBadMessage() = 0; | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 87 | |
| 88 // Track the count of visible widgets. Called by listeners to register and | |
| 89 // unregister visibility. | |
| 90 virtual void WidgetRestored() = 0; | |
| 91 virtual void WidgetHidden() = 0; | |
| 92 virtual int VisibleWidgetCount() const = 0; | |
| 93 | |
| 94 // Try to shutdown the associated renderer process as fast as possible. | |
| 95 // If this renderer has any RenderViews with unload handlers, then this | |
| 96 // function does nothing. The current implementation uses TerminateProcess. | |
| 97 // Returns True if it was able to do fast shutdown. | |
| 98 virtual bool FastShutdownIfPossible() = 0; | |
| 99 | |
| 100 // Dump the child process' handle table before shutting down. | |
| 101 virtual void DumpHandles() = 0; | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 102 | |
| 103 // Returns the process object associated with the child process. In certain | |
| 104 // tests or single-process mode, this will actually represent the current | |
| 105 // process. | |
| 106 // | |
| 107 // NOTE: this is not necessarily valid immediately after calling Init, as | |
| 108 // Init starts the process asynchronously. It's guaranteed to be valid after | |
| 109 // the first IPC arrives. | |
| 110 virtual base::ProcessHandle GetHandle() = 0; | |
| 111 | |
| 112 // Transport DIB functions --------------------------------------------------- | |
| 113 | |
| 114 // Return the TransportDIB for the given id. On Linux, this can involve | |
| 115 // mapping shared memory. On Mac, the shared memory is created in the browser | |
| 116 // process and the cached metadata is returned. On Windows, this involves | |
| 117 // duplicating the handle from the remote process. The RenderProcessHost | |
| 118 // still owns the returned DIB. | |
| 119 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) = 0; | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 120 | |
| 121 // RenderWidgetHost / compositing surface mapping functions ------------------ | |
| 122 | |
| 123 // Set a mapping from a RenderWidgetHost to a compositing surface. Pass a null | |
| 124 // handle to remove the mapping. | |
| 125 virtual void SetCompositingSurface( | |
|
jam
2011/11/11 03:24:29
ditto
| |
| 126 int render_widget_id, | |
| 127 gfx::PluginWindowHandle compositing_surface) = 0; | |
| 128 | |
| 129 // Static management functions ----------------------------------------------- | |
| 130 | |
| 131 // Flag to run the renderer in process. This is primarily | |
| 132 // for debugging purposes. When running "in process", the | |
| 133 // browser maintains a single RenderProcessHost which communicates | |
| 134 // to a RenderProcess which is instantiated in the same process | |
| 135 // with the Browser. All IPC between the Browser and the | |
| 136 // Renderer is the same, it's just not crossing a process boundary. | |
| 137 static bool run_renderer_in_process() { | |
| 138 return run_renderer_in_process_; | |
|
jam
2011/11/11 03:24:29
apart from not compiling, we should avoid member v
| |
| 139 } | |
| 140 static void set_run_renderer_in_process(bool value) { | |
| 141 run_renderer_in_process_ = value; | |
| 142 } | |
| 143 | |
| 144 // Allows iteration over all the RenderProcessHosts in the browser. Note | |
| 145 // that each host may not be active, and therefore may have NULL channels. | |
| 146 static iterator AllHostsIterator(); | |
| 147 | |
| 148 // Returns the RenderProcessHost given its ID. Returns NULL if the ID does | |
| 149 // not correspond to a live RenderProcessHost. | |
| 150 static RenderProcessHost* FromID(int render_process_id); | |
| 151 | |
| 152 // Returns true if the caller should attempt to use an existing | |
| 153 // RenderProcessHost rather than creating a new one. | |
| 154 static bool ShouldTryToUseExistingProcessHost(); | |
| 155 | |
| 156 // Get an existing RenderProcessHost associated with the given browser | |
| 157 // context, if possible. The renderer process is chosen randomly from | |
| 158 // suitable renderers that share the same context and type (determined by the | |
| 159 // site url). | |
| 160 // Returns NULL if no suitable renderer process is available, in which case | |
| 161 // the caller is free to create a new renderer. | |
| 162 static RenderProcessHost* GetExistingProcessHost( | |
| 163 content::BrowserContext* browser_context, const GURL& site_url); | |
| 164 | |
| 165 // Overrides the default heuristic for limiting the max renderer process | |
| 166 // count. This is useful for unit testing process limit behaviors. | |
| 167 // A value of zero means to use the default heuristic. | |
| 168 static void SetMaxRendererProcessCountForTest(size_t count); | |
| 169 }; | |
| 170 | |
| 171 #endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ | |
| 172 | |
| OLD | NEW |