render_process_host.h revision 116680a4aac90f2aa7413d9095a592090648e557
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/id_map.h" 1058e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch#include "base/process/kill.h" 1158e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch#include "base/process/process_handle.h" 124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "base/supports_user_data.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_channel_proxy.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_sender.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/native_widget_types.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GURL; 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct ViewMsg_SwapOut_Params; 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TimeDelta; 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class BrowserContext; 274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class BrowserMessageFilter; 28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class RenderProcessHostObserver; 294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class RenderWidgetHost; 30116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass ServiceRegistry; 314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class StoragePartition; 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct GlobalRequestID; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface that represents the browser side of the browser <-> renderer 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// communication channel. There will generally be one RenderProcessHost per 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// renderer process. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, 384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) public IPC::Listener, 394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) public base::SupportsUserData { 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef IDMap<RenderProcessHost>::iterator iterator; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Details for RENDERER_PROCESS_CLOSED notifications. 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct RendererClosedDetails { 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RendererClosedDetails(base::ProcessHandle handle, 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TerminationStatus status, 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int exit_code) { 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this->handle = handle; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this->status = status; 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this->exit_code = exit_code; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::ProcessHandle handle; 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TerminationStatus status; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int exit_code; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // General functions --------------------------------------------------------- 58f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~RenderProcessHost() {} 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initialize the new renderer process, returning true on success. This must 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be called once before the object can be used, but can be called after 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that with no effect. Therefore, if the caller isn't sure about whether 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the process has been created, it should just call Init(). 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool Init() = 0; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the next available routing id. 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetNextRoutingID() = 0; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // These methods add or remove listener for a specific message routing ID. 71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Used for refcounting, each holder of this object must AddRoute and 72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // RemoveRoute. This object should be allocated on the heap; when no 73eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // listeners own it any more, it will delete itself. 74eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0; 75eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch virtual void RemoveRoute(int32 routing_id) = 0; 76eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 77f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Add and remove observers for lifecycle events. The order in which 78f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // notifications are sent to observers is undefined. Observers must be sure to 79f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // remove the observer before they go away. 80f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void AddObserver(RenderProcessHostObserver* observer) = 0; 81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void RemoveObserver(RenderProcessHostObserver* observer) = 0; 82f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called when a received message cannot be decoded. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ReceivedBadMessage() = 0; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Track the count of visible widgets. Called by listeners to register and 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // unregister visibility. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WidgetRestored() = 0; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WidgetHidden() = 0; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int VisibleWidgetCount() const = 0; 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 92cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Indicates whether the current RenderProcessHost is associated with an 93cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // isolated guest renderer process. Not all guest renderers are created equal. 94cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // A guest, as indicated by BrowserPluginGuest::IsGuest, may coexist with 95cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // other non-guest renderers in the same process if IsIsolatedGuest is false. 96cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool IsIsolatedGuest() const = 0; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the storage partition associated with this process. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(nasko): Remove this function from the public API once 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // URLRequestContextGetter's creation is moved into StoragePartition. 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // http://crbug.com/158595 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual StoragePartition* GetStoragePartition() const = 0; 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Try to shutdown the associated renderer process as fast as possible. 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this renderer has any RenderViews with unload handlers, then this 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // function does nothing. The current implementation uses TerminateProcess. 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns True if it was able to do fast shutdown. 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool FastShutdownIfPossible() = 0; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if fast shutdown was started for the renderer. 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool FastShutdownStarted() const = 0; 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Dump the child process' handle table before shutting down. 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DumpHandles() = 0; 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the process object associated with the child process. In certain 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tests or single-process mode, this will actually represent the current 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // process. 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: this is not necessarily valid immediately after calling Init, as 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Init starts the process asynchronously. It's guaranteed to be valid after 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the first IPC arrives. 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual base::ProcessHandle GetHandle() const = 0; 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the user browser context associated with this renderer process. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual content::BrowserContext* GetBrowserContext() const = 0; 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether this process is using the same StoragePartition as 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |partition|. 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool InSameStoragePartition(StoragePartition* partition) const = 0; 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns the unique ID for this child process host. This can be used later 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in a call to FromID() to get back to this object (this is used to avoid 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sending non-threadsafe pointers to other threads). 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This ID will be unique across all child process hosts, including workers, 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // plugins, etc. 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This will never return ChildProcessHost::kInvalidUniqueID. 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetID() const = 0; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true iff channel_ has been set to non-NULL. Use this for checking 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // if there is connection or not. Virtual for mocking out for tests. 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HasConnection() const = 0; 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Call this to allow queueing of IPC messages that are sent before the 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // process is launched. 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void EnableSendQueue() = 0; 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the renderer channel. 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual IPC::ChannelProxy* GetChannel() = 0; 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Adds a message filter to the IPC channel. 1554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) virtual void AddFilter(BrowserMessageFilter* filter) = 0; 1564e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Try to shutdown the associated render process as fast as possible 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool FastShutdownForPageCount(size_t count) = 0; 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(ananta) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Revisit whether the virtual functions declared from here on need to be 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // part of the interface. 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IgnoreInputEvents() const = 0; 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Schedules the host for deletion and removes it from the all_hosts list. 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Cleanup() = 0; 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Track the count of pending views that are being swapped back in. Called 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // by listeners to register and unregister pending views to prevent the 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // process from exiting. 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void AddPendingView() = 0; 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void RemovePendingView() = 0; 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets a flag indicating that the process can be abnormally terminated. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetSuddenTerminationAllowed(bool allowed) = 0; 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the process can be abnormally terminated. 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool SuddenTerminationAllowed() const = 0; 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns how long the child has been idle. The definition of idle 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // depends on when a derived class calls mark_child_process_activity_time(). 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is a rough indicator and its resolution should not be better than 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 10 milliseconds. 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual base::TimeDelta GetChildProcessIdleTime() const = 0; 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to resume the requests for a view created through window.open that 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // were initially blocked. 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ResumeRequestsForView(int route_id) = 0; 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Checks that the given renderer can request |url|, if not it sets it to 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // about:blank. 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |empty_allowed| must be set to false for navigations for security reasons. 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void FilterURL(bool empty_allowed, GURL* url) = 0; 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(ENABLE_WEBRTC) 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void EnableAecDump(const base::FilePath& file) = 0; 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void DisableAecDump() = 0; 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // When set, |callback| receives log messages regarding, for example, media 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // devices (webcams, mics, etc) that were initially requested in the render 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // process associated with this RenderProcessHost. 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void SetWebRtcLogMessageCallback( 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Callback<void(const std::string&)> callback) = 0; 20446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 20546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) typedef base::Callback<void(scoped_ptr<uint8[]> packet_header, 20646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) size_t header_length, 20746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) size_t packet_length, 20846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool incoming)> WebRtcRtpPacketCallback; 20946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 21046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) typedef base::Callback<void(bool incoming, bool outgoing)> 21146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) WebRtcStopRtpDumpCallback; 21246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 21346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // Starts passing RTP packets to |packet_callback| and returns the callback 21446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // used to stop dumping. 21546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual WebRtcStopRtpDumpCallback StartRtpDump( 21646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool incoming, 21746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool outgoing, 21846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) const WebRtcRtpPacketCallback& packet_callback) = 0; 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Tells the ResourceDispatcherHost to resume a deferred navigation without 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // transferring it to a new renderer process. 2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void ResumeDeferredNavigation(const GlobalRequestID& request_id) = 0; 2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 225a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Notifies the renderer that the timezone configuration of the system might 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // have changed. 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void NotifyTimezoneChange() = 0; 228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 229116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Returns the ServiceRegistry for this process. 230116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ServiceRegistry* GetServiceRegistry() = 0; 231116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Static management functions ----------------------------------------------- 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Flag to run the renderer in process. This is primarily 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for debugging purposes. When running "in process", the 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // browser maintains a single RenderProcessHost which communicates 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to a RenderProcess which is instantiated in the same process 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // with the Browser. All IPC between the Browser and the 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Renderer is the same, it's just not crossing a process boundary. 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool run_renderer_in_process(); 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This also calls out to ContentBrowserClient::GetApplicationLocale and 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // modifies the current process' command line. 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void SetRunRendererInProcess(bool value); 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Allows iteration over all the RenderProcessHosts in the browser. Note 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that each host may not be active, and therefore may have NULL channels. 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static iterator AllHostsIterator(); 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the RenderProcessHost given its ID. Returns NULL if the ID does 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not correspond to a live RenderProcessHost. 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static RenderProcessHost* FromID(int render_process_id); 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2557d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Returns whether the process-per-site model is in use (globally or just for 2567d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // the current site), in which case we should ensure there is only one 2577d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // RenderProcessHost per site for the entire browser context. 2587d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) static bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, 2597d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const GURL& url); 2607d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the caller should attempt to use an existing 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderProcessHost rather than creating a new one. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool ShouldTryToUseExistingProcessHost( 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::BrowserContext* browser_context, const GURL& site_url); 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get an existing RenderProcessHost associated with the given browser 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // context, if possible. The renderer process is chosen randomly from 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // suitable renderers that share the same context and type (determined by the 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // site url). 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns NULL if no suitable renderer process is available, in which case 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the caller is free to create a new renderer. 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static RenderProcessHost* GetExistingProcessHost( 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::BrowserContext* browser_context, const GURL& site_url); 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overrides the default heuristic for limiting the max renderer process 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // count. This is useful for unit testing process limit behaviors. It is 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // also used to allow a command line parameter to configure the max number of 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // renderer processes and should only be called once during startup. 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A value of zero means to use the default heuristic. 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void SetMaxRendererProcessCount(size_t count); 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the current max number of renderer processes used by the content 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // module. 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static size_t GetMaxRendererProcessCount(); 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content. 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_ 290