render_process_host.h revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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;
304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class StoragePartition;
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct GlobalRequestID;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface that represents the browser side of the browser <-> renderer
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// communication channel. There will generally be one RenderProcessHost per
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// renderer process.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT RenderProcessHost : public IPC::Sender,
374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                                         public IPC::Listener,
384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                                         public base::SupportsUserData {
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  typedef IDMap<RenderProcessHost>::iterator iterator;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Details for RENDERER_PROCESS_CLOSED notifications.
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct RendererClosedDetails {
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    RendererClosedDetails(base::ProcessHandle handle,
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          base::TerminationStatus status,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          int exit_code) {
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      this->handle = handle;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      this->status = status;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      this->exit_code = exit_code;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    base::ProcessHandle handle;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    base::TerminationStatus status;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    int exit_code;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
56f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // General functions ---------------------------------------------------------
57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~RenderProcessHost() {}
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Initialize the new renderer process, returning true on success. This must
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // be called once before the object can be used, but can be called after
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that with no effect. Therefore, if the caller isn't sure about whether
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the process has been created, it should just call Init().
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Init() = 0;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets the next available routing id.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetNextRoutingID() = 0;
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
69eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // These methods add or remove listener for a specific message routing ID.
70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Used for refcounting, each holder of this object must AddRoute and
71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // RemoveRoute. This object should be allocated on the heap; when no
72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // listeners own it any more, it will delete itself.
73eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual void AddRoute(int32 routing_id, IPC::Listener* listener) = 0;
74eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual void RemoveRoute(int32 routing_id) = 0;
75eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
76f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Add and remove observers for lifecycle events. The order in which
77f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // notifications are sent to observers is undefined. Observers must be sure to
78f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // remove the observer before they go away.
79f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void AddObserver(RenderProcessHostObserver* observer) = 0;
80f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void RemoveObserver(RenderProcessHostObserver* observer) = 0;
81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to wait for the next UpdateRect message for the specified render
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // widget.  Returns true if successful, and the msg out-param will contain a
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // copy of the received UpdateRect message.
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool WaitForBackingStoreMsg(int render_widget_id,
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      const base::TimeDelta& max_delay,
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                      IPC::Message* msg) = 0;
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a received message cannot be decoded.
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ReceivedBadMessage() = 0;
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Track the count of visible widgets. Called by listeners to register and
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // unregister visibility.
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WidgetRestored() = 0;
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void WidgetHidden() = 0;
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int VisibleWidgetCount() const = 0;
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
98cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Indicates whether the current RenderProcessHost is associated with an
99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // isolated guest renderer process. Not all guest renderers are created equal.
100cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // A guest, as indicated by BrowserPluginGuest::IsGuest, may coexist with
101cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // other non-guest renderers in the same process if IsIsolatedGuest is false.
102cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual bool IsIsolatedGuest() const = 0;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the storage partition associated with this process.
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(nasko): Remove this function from the public API once
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // URLRequestContextGetter's creation is moved into StoragePartition.
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // http://crbug.com/158595
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual StoragePartition* GetStoragePartition() const = 0;
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Try to shutdown the associated renderer process as fast as possible.
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If this renderer has any RenderViews with unload handlers, then this
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // function does nothing.  The current implementation uses TerminateProcess.
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns True if it was able to do fast shutdown.
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool FastShutdownIfPossible() = 0;
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if fast shutdown was started for the renderer.
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool FastShutdownStarted() const = 0;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Dump the child process' handle table before shutting down.
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DumpHandles() = 0;
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the process object associated with the child process.  In certain
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tests or single-process mode, this will actually represent the current
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process.
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: this is not necessarily valid immediately after calling Init, as
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Init starts the process asynchronously.  It's guaranteed to be valid after
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the first IPC arrives.
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual base::ProcessHandle GetHandle() const = 0;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the user browser context associated with this renderer process.
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual content::BrowserContext* GetBrowserContext() const = 0;
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns whether this process is using the same StoragePartition as
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |partition|.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool InSameStoragePartition(StoragePartition* partition) const = 0;
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the unique ID for this child process host. This can be used later
1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // in a call to FromID() to get back to this object (this is used to avoid
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // sending non-threadsafe pointers to other threads).
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // This ID will be unique across all child process hosts, including workers,
1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // plugins, etc.
1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // This will never return ChildProcessHost::kInvalidUniqueID.
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetID() const = 0;
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true iff channel_ has been set to non-NULL. Use this for checking
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // if there is connection or not. Virtual for mocking out for tests.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HasConnection() const = 0;
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Call this to allow queueing of IPC messages that are sent before the
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process is launched.
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void EnableSendQueue() = 0;
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the renderer channel.
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual IPC::ChannelProxy* GetChannel() = 0;
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Adds a message filter to the IPC channel.
1614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void AddFilter(BrowserMessageFilter* filter) = 0;
1624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Try to shutdown the associated render process as fast as possible
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool FastShutdownForPageCount(size_t count) = 0;
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(ananta)
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Revisit whether the virtual functions declared from here on need to be
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // part of the interface.
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0;
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool IgnoreInputEvents() const = 0;
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Schedules the host for deletion and removes it from the all_hosts list.
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Cleanup() = 0;
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Track the count of pending views that are being swapped back in.  Called
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by listeners to register and unregister pending views to prevent the
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process from exiting.
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void AddPendingView() = 0;
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RemovePendingView() = 0;
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets a flag indicating that the process can be abnormally terminated.
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void SetSuddenTerminationAllowed(bool allowed) = 0;
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the process can be abnormally terminated.
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool SuddenTerminationAllowed() const = 0;
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns how long the child has been idle. The definition of idle
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // depends on when a derived class calls mark_child_process_activity_time().
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is a rough indicator and its resolution should not be better than
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // 10 milliseconds.
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual base::TimeDelta GetChildProcessIdleTime() const = 0;
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called to resume the requests for a view created through window.open that
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // were initially blocked.
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ResumeRequestsForView(int route_id) = 0;
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Checks that the given renderer can request |url|, if not it sets it to
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // about:blank.
1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // |empty_allowed| must be set to false for navigations for security reasons.
1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void FilterURL(bool empty_allowed, GURL* url) = 0;
2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(ENABLE_WEBRTC)
2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void EnableAecDump(const base::FilePath& file) = 0;
2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DisableAecDump() = 0;
2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // When set, |callback| receives log messages regarding, for example, media
2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // devices (webcams, mics, etc) that were initially requested in the render
2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // process associated with this RenderProcessHost.
2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void SetWebRtcLogMessageCallback(
2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Callback<void(const std::string&)> callback) = 0;
2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif
2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Tells the ResourceDispatcherHost to resume a deferred navigation without
2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // transferring it to a new renderer process.
2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void ResumeDeferredNavigation(const GlobalRequestID& request_id) = 0;
2155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Notifies the renderer that the timezone configuration of the system might
217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // have changed.
218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void NotifyTimezoneChange() = 0;
219a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Static management functions -----------------------------------------------
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Flag to run the renderer in process.  This is primarily
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for debugging purposes.  When running "in process", the
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // browser maintains a single RenderProcessHost which communicates
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to a RenderProcess which is instantiated in the same process
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // with the Browser.  All IPC between the Browser and the
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Renderer is the same, it's just not crossing a process boundary.
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool run_renderer_in_process();
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This also calls out to ContentBrowserClient::GetApplicationLocale and
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // modifies the current process' command line.
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void SetRunRendererInProcess(bool value);
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows iteration over all the RenderProcessHosts in the browser. Note
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that each host may not be active, and therefore may have NULL channels.
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static iterator AllHostsIterator();
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the RenderProcessHost given its ID.  Returns NULL if the ID does
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not correspond to a live RenderProcessHost.
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static RenderProcessHost* FromID(int render_process_id);
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Returns whether the process-per-site model is in use (globally or just for
2447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // the current site), in which case we should ensure there is only one
2457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // RenderProcessHost per site for the entire browser context.
2467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  static bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
2477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                                      const GURL& url);
2487d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if the caller should attempt to use an existing
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // RenderProcessHost rather than creating a new one.
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool ShouldTryToUseExistingProcessHost(
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::BrowserContext* browser_context, const GURL& site_url);
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Get an existing RenderProcessHost associated with the given browser
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // context, if possible.  The renderer process is chosen randomly from
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // suitable renderers that share the same context and type (determined by the
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // site url).
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns NULL if no suitable renderer process is available, in which case
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the caller is free to create a new renderer.
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static RenderProcessHost* GetExistingProcessHost(
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::BrowserContext* browser_context, const GURL& site_url);
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overrides the default heuristic for limiting the max renderer process
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // count.  This is useful for unit testing process limit behaviors.  It is
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // also used to allow a command line parameter to configure the max number of
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // renderer processes and should only be called once during startup.
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // A value of zero means to use the default heuristic.
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void SetMaxRendererProcessCount(size_t count);
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the current max number of renderer processes used by the content
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // module.
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static size_t GetMaxRendererProcessCount();
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content.
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_RENDER_PROCESS_HOST_H_
278