diff options
Diffstat (limited to 'content/browser')
60 files changed, 828 insertions, 876 deletions
diff --git a/content/browser/cert_store.cc b/content/browser/cert_store.cc index b6501c4..594f0bc 100644 --- a/content/browser/cert_store.cc +++ b/content/browser/cert_store.cc @@ -8,7 +8,7 @@ #include <functional> #include "base/stl_util.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" @@ -154,7 +154,8 @@ void CertStore::Observe(int type, const content::NotificationDetails& details) { DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED || type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED); - RenderProcessHost* rph = content::Source<RenderProcessHost>(source).ptr(); + content::RenderProcessHost* rph = + content::Source<content::RenderProcessHost>(source).ptr(); DCHECK(rph); - RemoveCertsForRenderProcesHost(rph->id()); + RemoveCertsForRenderProcesHost(rph->GetID()); } diff --git a/content/browser/child_process_security_policy_browsertest.cc b/content/browser/child_process_security_policy_browsertest.cc index a70d1c6..1a85e0b 100644 --- a/content/browser/child_process_security_policy_browsertest.cc +++ b/content/browser/child_process_security_policy_browsertest.cc @@ -11,8 +11,8 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/renderer_host/render_process_host.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/render_process_host.h" #include "content/public/common/result_codes.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc index 99dc4d0..53467b2 100644 --- a/content/browser/debugger/render_view_devtools_agent_host.cc +++ b/content/browser/debugger/render_view_devtools_agent_host.cc @@ -8,7 +8,7 @@ #include "base/lazy_instance.h" #include "content/browser/debugger/devtools_manager.h" #include "content/browser/debugger/render_view_devtools_agent_host.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" @@ -64,12 +64,13 @@ void RenderViewDevToolsAgentHost::NotifyClientClosing() { content::NotificationService::current()->Notify( content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, content::Source<content::BrowserContext>( - render_view_host_->site_instance()->GetProcess()->browser_context()), + render_view_host_->site_instance()->GetProcess()-> + GetBrowserContext()), content::Details<RenderViewHost>(render_view_host_)); } int RenderViewDevToolsAgentHost::GetRenderProcessId() { - return render_view_host_->process()->id(); + return render_view_host_->process()->GetID(); } RenderViewDevToolsAgentHost::~RenderViewDevToolsAgentHost() { diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 62dd7e8..f1a7309 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -25,7 +25,6 @@ #include "content/browser/download/download_stats.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/interrupt_reasons.h" -#include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/tab_contents/tab_contents.h" @@ -34,6 +33,7 @@ #include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" using content::BrowserThread; @@ -730,7 +730,7 @@ void DownloadManagerImpl::DownloadUrlToFile(const GURL& url, BrowserThread::IO, FROM_HERE, base::Bind(&BeginDownload, URLParams(url, referrer), save_info, resource_dispatcher_host, - RenderParams(tab_contents->GetRenderProcessHost()->id(), + RenderParams(tab_contents->GetRenderProcessHost()->GetID(), tab_contents->render_view_host()->routing_id()), &tab_contents->browser_context()->GetResourceContext())); } diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc index 638006e..4f6b967 100644 --- a/content/browser/download/download_request_handle.cc +++ b/content/browser/download/download_request_handle.cc @@ -67,10 +67,10 @@ DownloadManager* DownloadRequestHandle::GetDownloadManager() const { RenderViewHost* rvh = RenderViewHost::FromID(child_id_, render_view_id_); if (rvh == NULL) return NULL; - RenderProcessHost* rph = rvh->process(); + content::RenderProcessHost* rph = rvh->process(); if (rph == NULL) return NULL; - content::BrowserContext* context = rph->browser_context(); + content::BrowserContext* context = rph->GetBrowserContext(); if (context == NULL) return NULL; return context->GetDownloadManager(); diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc index 4dc70b2..7a63009 100644 --- a/content/browser/download/mhtml_generation_manager.cc +++ b/content/browser/download/mhtml_generation_manager.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/platform_file.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" @@ -36,7 +36,7 @@ void MHTMLGenerationManager::GenerateMHTML(TabContents* tab_contents, int job_id = id_counter++; Job job; job.file_path = file; - job.process_id = tab_contents->GetRenderProcessHost()->id(); + job.process_id = tab_contents->GetRenderProcessHost()->GetID(); job.routing_id = tab_contents->render_view_host()->routing_id(); id_to_job_[job_id] = job; diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index bc96e89..9abb497 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -25,7 +25,7 @@ #include "content/browser/download/save_file.h" #include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_item.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -129,7 +129,7 @@ SavePackage::SavePackage(TabContents* tab_contents, save_type_(save_type), all_save_items_count_(0), wait_state_(INITIALIZE), - tab_id_(tab_contents->GetRenderProcessHost()->id()), + tab_id_(tab_contents->GetRenderProcessHost()->GetID()), unique_id_(g_save_package_id++), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(page_url_.is_valid()); @@ -155,7 +155,7 @@ SavePackage::SavePackage(TabContents* tab_contents) save_type_(SAVE_TYPE_UNKNOWN), all_save_items_count_(0), wait_state_(INITIALIZE), - tab_id_(tab_contents->GetRenderProcessHost()->id()), + tab_id_(tab_contents->GetRenderProcessHost()->GetID()), unique_id_(g_save_package_id++), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(page_url_.is_valid()); @@ -653,7 +653,7 @@ void SavePackage::CheckFinish() { file_manager_, final_names, dir, - tab_contents()->GetRenderProcessHost()->id(), + tab_contents()->GetRenderProcessHost()->GetID(), tab_contents()->render_view_host()->routing_id(), id())); } @@ -801,7 +801,7 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) { save_item->Start(); file_manager_->SaveURL(save_item->url(), save_item->referrer(), - tab_contents()->GetRenderProcessHost()->id(), + tab_contents()->GetRenderProcessHost()->GetID(), routing_id(), save_item->save_source(), save_item->full_path(), diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc index 8458b3a..af23aea 100644 --- a/content/browser/geolocation/geolocation_dispatcher_host.cc +++ b/content/browser/geolocation/geolocation_dispatcher_host.cc @@ -11,7 +11,7 @@ #include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/geolocation/geolocation_provider.h" #include "content/browser/renderer_host/render_message_filter.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/common/geolocation_messages.h" #include "content/common/geoposition.h" diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index de484b3..e734f79 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -12,7 +12,7 @@ #include "base/process_util.h" #include "content/browser/gpu/gpu_data_manager.h" #include "content/browser/gpu/gpu_process_host.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/common/gpu/gpu_messages.h" diff --git a/content/browser/host_zoom_map.cc b/content/browser/host_zoom_map.cc index cec946a..b827433 100644 --- a/content/browser/host_zoom_map.cc +++ b/content/browser/host_zoom_map.cc @@ -9,7 +9,7 @@ #include "base/string_piece.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" @@ -128,7 +128,7 @@ void HostZoomMap::Observe( int render_view_id = content::Source<RenderViewHost>(source)->routing_id(); int render_process_id = - content::Source<RenderViewHost>(source)->process()->id(); + content::Source<RenderViewHost>(source)->process()->GetID(); for (size_t i = 0; i < temporary_zoom_levels_.size(); ++i) { if (temporary_zoom_levels_[i].render_process_id == render_process_id && diff --git a/content/browser/mach_broker_mac.cc b/content/browser/mach_broker_mac.cc index b604f48..09f3e75 100644 --- a/content/browser/mach_broker_mac.cc +++ b/content/browser/mach_broker_mac.cc @@ -12,7 +12,7 @@ #include "base/stringprintf.h" #include "base/sys_string_conversions.h" #include "base/threading/platform_thread.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/common/child_process_info.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" @@ -211,11 +211,12 @@ void MachBroker::Observe(int type, switch (type) { case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: handle = - content::Details<RenderProcessHost::RendererClosedDetails>(details)-> - handle; + content::Details<content::RenderProcessHost::RendererClosedDetails>( + details)->handle; break; case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: - handle = content::Source<RenderProcessHost>(source)->GetHandle(); + handle = content::Source<content::RenderProcessHost>(source)-> + GetHandle(); break; case content::NOTIFICATION_CHILD_PROCESS_CRASHED: case content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED: diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index 8af17b3..79c8404 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -42,8 +42,8 @@ void MockContentBrowserClient::RenderViewHostCreated( RenderViewHost* render_view_host) { } -void MockContentBrowserClient::BrowserRenderProcessHostCreated( - BrowserRenderProcessHost* host) { +void MockContentBrowserClient::RenderProcessHostCreated( + RenderProcessHost* host) { } void MockContentBrowserClient::PluginProcessHostCreated( diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h index cdc8406..2fcd957 100644 --- a/content/browser/mock_content_browser_client.h +++ b/content/browser/mock_content_browser_client.h @@ -30,8 +30,8 @@ class MockContentBrowserClient : public ContentBrowserClient { TabContents* tab_contents) OVERRIDE; virtual void RenderViewHostCreated( RenderViewHost* render_view_host) OVERRIDE; - virtual void BrowserRenderProcessHostCreated( - BrowserRenderProcessHost* host) OVERRIDE; + virtual void RenderProcessHostCreated( + RenderProcessHost* host) OVERRIDE; virtual void PluginProcessHostCreated(PluginProcessHost* host) OVERRIDE; virtual WebUIFactory* GetWebUIFactory() OVERRIDE; virtual GURL GetEffectiveURL(content::BrowserContext* browser_context, diff --git a/content/browser/net/browser_online_state_observer.cc b/content/browser/net/browser_online_state_observer.cc index 2b0ccd8..348f8ba 100644 --- a/content/browser/net/browser_online_state_observer.cc +++ b/content/browser/net/browser_online_state_observer.cc @@ -4,8 +4,8 @@ #include "content/browser/net/browser_online_state_observer.h" -#include "content/browser/renderer_host/render_process_host.h" #include "content/common/view_messages.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "net/base/network_change_notifier.h" BrowserOnlineStateObserver::BrowserOnlineStateObserver() { @@ -17,7 +17,8 @@ BrowserOnlineStateObserver::~BrowserOnlineStateObserver() { } void BrowserOnlineStateObserver::OnOnlineStateChanged(bool online) { - for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); + for (content::RenderProcessHost::iterator it( + content::RenderProcessHost::AllHostsIterator()); !it.IsAtEnd(); it.Advance()) { it.GetCurrentValue()->Send(new ViewMsg_NetworkStateChanged(online)); } diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc index b4b47f5..1655987 100644 --- a/content/browser/plugin_service.cc +++ b/content/browser/plugin_service.cc @@ -19,7 +19,7 @@ #include "content/browser/plugin_loader_posix.h" #include "content/browser/plugin_service_filter.h" #include "content/browser/ppapi_plugin_process_host.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/resource_context.h" #include "content/browser/utility_process_host.h" @@ -573,10 +573,11 @@ void PluginService::Observe(int type, void PluginService::PurgePluginListCache( content::BrowserContext* browser_context, bool reload_pages) { - for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); + for (content::RenderProcessHost::iterator it = + content::RenderProcessHost::AllHostsIterator(); !it.IsAtEnd(); it.Advance()) { - RenderProcessHost* host = it.GetCurrentValue(); - if (!browser_context || host->browser_context() == browser_context) + content::RenderProcessHost* host = it.GetCurrentValue(); + if (!browser_context || host->GetBrowserContext() == browser_context) host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); } } diff --git a/content/browser/renderer_host/backing_store.h b/content/browser/renderer_host/backing_store.h index ef4dd8e..d17a7b9 100644 --- a/content/browser/renderer_host/backing_store.h +++ b/content/browser/renderer_host/backing_store.h @@ -21,6 +21,10 @@ namespace gfx { class Rect; } +namespace content { +class RenderProcessHost; +} + namespace skia { class PlatformCanvas; } @@ -47,7 +51,7 @@ class CONTENT_EXPORT BackingStore { // the time it returns, in which case it will set |scheduled_callback| to // true and will call |callback| when completed. virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_gtk.cc b/content/browser/renderer_host/backing_store_gtk.cc index efae772..06d2e66 100644 --- a/content/browser/renderer_host/backing_store_gtk.cc +++ b/content/browser/renderer_host/backing_store_gtk.cc @@ -25,7 +25,7 @@ #include "base/memory/singleton.h" #include "base/metrics/histogram.h" #include "base/time.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/x/x11_util.h" @@ -328,7 +328,7 @@ void BackingStoreGtk::PaintRectWithoutXrender( } void BackingStoreGtk::PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_gtk.h b/content/browser/renderer_host/backing_store_gtk.h index b69862e..cede176 100644 --- a/content/browser/renderer_host/backing_store_gtk.h +++ b/content/browser/renderer_host/backing_store_gtk.h @@ -19,6 +19,7 @@ class Point; class Rect; } // namespace gfx + typedef struct _GdkDrawable GdkDrawable; class CONTENT_EXPORT BackingStoreGtk : public BackingStore { @@ -58,7 +59,7 @@ class CONTENT_EXPORT BackingStoreGtk : public BackingStore { // BackingStore implementation. virtual size_t MemorySize() OVERRIDE; virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_mac.h b/content/browser/renderer_host/backing_store_mac.h index ed6801d..06031c2 100644 --- a/content/browser/renderer_host/backing_store_mac.h +++ b/content/browser/renderer_host/backing_store_mac.h @@ -25,7 +25,7 @@ class BackingStoreMac : public BackingStore { // BackingStore implementation. virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm index df5ee9e..b9972a7 100644 --- a/content/browser/renderer_host/backing_store_mac.mm +++ b/content/browser/renderer_host/backing_store_mac.mm @@ -9,7 +9,7 @@ #include "base/logging.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "skia/ext/platform_canvas.h" @@ -39,7 +39,7 @@ BackingStoreMac::~BackingStoreMac() { } void BackingStoreMac::PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_skia.cc b/content/browser/renderer_host/backing_store_skia.cc index ff2cc41..300e4fe 100644 --- a/content/browser/renderer_host/backing_store_skia.cc +++ b/content/browser/renderer_host/backing_store_skia.cc @@ -4,7 +4,7 @@ #include "content/browser/renderer_host/backing_store_skia.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/gfx/canvas.h" @@ -42,7 +42,7 @@ size_t BackingStoreSkia::MemorySize() { } void BackingStoreSkia::PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_skia.h b/content/browser/renderer_host/backing_store_skia.h index da3a81d..b713a84 100644 --- a/content/browser/renderer_host/backing_store_skia.h +++ b/content/browser/renderer_host/backing_store_skia.h @@ -18,6 +18,10 @@ class Point; class Canvas; } +namespace content { +class RenderProcessHost; +} + // A backing store that uses skia. This is a temporary backing store used by // RenderWidgetHostViewViews. In time, only GPU rendering will be used for // RWHVV, and then this backing store will be removed. @@ -35,7 +39,7 @@ class BackingStoreSkia : public BackingStore { // BackingStore implementation. virtual size_t MemorySize() OVERRIDE; virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_win.cc b/content/browser/renderer_host/backing_store_win.cc index df99136..632a32d 100644 --- a/content/browser/renderer_host/backing_store_win.cc +++ b/content/browser/renderer_host/backing_store_win.cc @@ -5,7 +5,7 @@ #include "content/browser/renderer_host/backing_store_win.h" #include "base/command_line.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/public/common/content_switches.h" #include "skia/ext/platform_canvas.h" @@ -114,7 +114,7 @@ size_t BackingStoreWin::MemorySize() { } void BackingStoreWin::PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/backing_store_win.h b/content/browser/renderer_host/backing_store_win.h index 6690cc2..bf0e408 100644 --- a/content/browser/renderer_host/backing_store_win.h +++ b/content/browser/renderer_host/backing_store_win.h @@ -24,7 +24,7 @@ class BackingStoreWin : public BackingStore { // BackingStore implementation. virtual size_t MemorySize() OVERRIDE; virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc index 685789d..c6a680d 100644 --- a/content/browser/renderer_host/mock_render_process_host.cc +++ b/content/browser/renderer_host/mock_render_process_host.cc @@ -4,24 +4,46 @@ #include "content/browser/renderer_host/mock_render_process_host.h" +#include "base/lazy_instance.h" +#include "base/message_loop.h" +#include "base/time.h" #include "content/browser/child_process_security_policy.h" +#include "content/common/child_process_info.h" +#include "content/public/browser/notification_service.h" +#include "content/public/browser/notification_types.h" + +// This map is the global list of all renderer processes and is defined in +// render_process_host_impl.cc +// TODO(ananta) +// Clean up this dependency in a subsequent CL. +extern base::LazyInstance< + IDMap<content::RenderProcessHost>, + base::LeakyLazyInstanceTraits<IDMap<content::RenderProcessHost> > > + g_all_hosts; MockRenderProcessHost::MockRenderProcessHost( content::BrowserContext* browser_context) - : RenderProcessHost(browser_context), - transport_dib_(NULL), + : transport_dib_(NULL), bad_msg_count_(0), - factory_(NULL) { + factory_(NULL), + id_(ChildProcessInfo::GenerateChildProcessUniqueId()), + browser_context_(browser_context), + max_page_id_(-1), + fast_shutdown_started_(false) { // Child process security operations can't be unit tested unless we add // ourselves as an existing child process. - ChildProcessSecurityPolicy::GetInstance()->Add(id()); + ChildProcessSecurityPolicy::GetInstance()->Add(GetID()); + g_all_hosts.Get().AddWithID(this, GetID()); } MockRenderProcessHost::~MockRenderProcessHost() { - ChildProcessSecurityPolicy::GetInstance()->Remove(id()); + ChildProcessSecurityPolicy::GetInstance()->Remove(GetID()); delete transport_dib_; if (factory_) factory_->Remove(this); + // In unit tests, Release() might not have been called. + if (g_all_hosts.Get().Lookup(GetID())) + g_all_hosts.Get().Remove(GetID()); } void MockRenderProcessHost::EnableSendQueue() { @@ -70,7 +92,6 @@ int MockRenderProcessHost::VisibleWidgetCount() const { void MockRenderProcessHost::AddWord(const string16& word) { } - bool MockRenderProcessHost::FastShutdownIfPossible() { // We aren't actually going to do anything, but set |fast_shutdown_started_| // to true so that tests know we've been called. @@ -78,6 +99,10 @@ bool MockRenderProcessHost::FastShutdownIfPossible() { return true; } +bool MockRenderProcessHost::FastShutdownStarted() const { + return fast_shutdown_started_; +} + void MockRenderProcessHost::DumpHandles() { } @@ -116,6 +141,92 @@ void MockRenderProcessHost::SetCompositingSurface( gfx::PluginWindowHandle compositing_surface) { } +int MockRenderProcessHost::GetID() const { + return id_; +} + +bool MockRenderProcessHost::HasConnection() const { + return true; +} + +void MockRenderProcessHost::SetIgnoreInputEvents(bool ignore_input_events) { +} + +bool MockRenderProcessHost::IgnoreInputEvents() const { + return false; +} + +void MockRenderProcessHost::Attach(IPC::Channel::Listener* listener, + int routing_id) { + listeners_.AddWithID(listener, routing_id); +} + +void MockRenderProcessHost::Release(int listener_id) { + listeners_.Remove(listener_id); + Cleanup(); +} + +void MockRenderProcessHost::Cleanup() { + if (listeners_.IsEmpty()) { + content::NotificationService::current()->Notify( + content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, + content::Source<RenderProcessHost>(this), + content::NotificationService::NoDetails()); + MessageLoop::current()->DeleteSoon(FROM_HERE, this); + g_all_hosts.Get().Remove(GetID()); + } +} + +void MockRenderProcessHost::ReportExpectingClose(int32 listener_id) { +} + +void MockRenderProcessHost::AddPendingView() { +} + +void MockRenderProcessHost::RemovePendingView() { +} + +void MockRenderProcessHost::SetSuddenTerminationAllowed(bool allowed) { +} + +bool MockRenderProcessHost::SuddenTerminationAllowed() const { + return true; +} + +IPC::Channel::Listener* MockRenderProcessHost::GetListenerByID( + int routing_id) { + return listeners_.Lookup(routing_id); +} + +void MockRenderProcessHost::UpdateMaxPageID(int32 page_id) { + if (page_id > max_page_id_) + max_page_id_ = page_id; +} + +content::BrowserContext* MockRenderProcessHost::GetBrowserContext() const { + return browser_context_; +} + +IPC::ChannelProxy* MockRenderProcessHost::GetChannel() { + return NULL; +} + +bool MockRenderProcessHost::FastShutdownForPageCount(size_t count) { + if (listeners_.size() == count) + return FastShutdownIfPossible(); + return false; +} + +base::TimeDelta MockRenderProcessHost::GetChildProcessIdleTime() const { + return base::TimeDelta::FromMilliseconds(0); +} + +content::RenderProcessHost::listeners_iterator + MockRenderProcessHost::ListenersIterator() { + IDMap<IPC::Channel::Listener> listeners; + return listeners_iterator(&listeners); +} + bool MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { return false; } @@ -134,8 +245,9 @@ MockRenderProcessHostFactory::~MockRenderProcessHostFactory() { } } -RenderProcessHost* MockRenderProcessHostFactory::CreateRenderProcessHost( - content::BrowserContext* browser_context) const { +content::RenderProcessHost* + MockRenderProcessHostFactory::CreateRenderProcessHost( + content::BrowserContext* browser_context) const { MockRenderProcessHost* host = new MockRenderProcessHost(browser_context); if (host) { processes_.push_back(host); diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h index 77aa067..9e8c49e 100644 --- a/content/browser/renderer_host/mock_render_process_host.h +++ b/content/browser/renderer_host/mock_render_process_host.h @@ -8,7 +8,8 @@ #include "base/basictypes.h" #include "base/memory/scoped_vector.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/render_process_host_factory.h" #include "ipc/ipc_test_sink.h" class MockRenderProcessHostFactory; @@ -16,7 +17,7 @@ class TransportDIB; // A mock render process host that has no corresponding renderer process. All // IPC messages are sent into the message sink for inspection by tests. -class MockRenderProcessHost : public RenderProcessHost { +class MockRenderProcessHost : public content::RenderProcessHost { public: explicit MockRenderProcessHost(content::BrowserContext* browser_context); virtual ~MockRenderProcessHost(); @@ -47,13 +48,34 @@ class MockRenderProcessHost : public RenderProcessHost { virtual void WidgetHidden() OVERRIDE; virtual int VisibleWidgetCount() const OVERRIDE; virtual void AddWord(const string16& word); - virtual bool FastShutdownIfPossible() OVERRIDE; - virtual void DumpHandles() OVERRIDE; - virtual base::ProcessHandle GetHandle() OVERRIDE; - virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; + virtual bool FastShutdownIfPossible(); + virtual bool FastShutdownStarted() const; + virtual void DumpHandles(); + virtual base::ProcessHandle GetHandle(); + virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id); virtual void SetCompositingSurface( int render_widget_id, gfx::PluginWindowHandle compositing_surface) OVERRIDE; + virtual int GetID() const OVERRIDE; + virtual bool HasConnection() const OVERRIDE; + virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; + virtual bool IgnoreInputEvents() const OVERRIDE; + virtual void Attach(IPC::Channel::Listener* listener, + int routing_id) OVERRIDE; + virtual void Release(int listener_id) OVERRIDE; + virtual void Cleanup() OVERRIDE; + virtual void ReportExpectingClose(int32 listener_id) OVERRIDE; + virtual void AddPendingView() OVERRIDE; + virtual void RemovePendingView() OVERRIDE; + virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; + virtual bool SuddenTerminationAllowed() const OVERRIDE; + virtual void UpdateMaxPageID(int32 page_id) OVERRIDE; + virtual IPC::Channel::Listener* GetListenerByID(int routing_id) OVERRIDE; + virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; + virtual IPC::ChannelProxy* GetChannel() OVERRIDE; + virtual listeners_iterator ListenersIterator() OVERRIDE; + virtual bool FastShutdownForPageCount(size_t count) OVERRIDE; + virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE; // IPC::Channel::Sender via RenderProcessHost. virtual bool Send(IPC::Message* msg) OVERRIDE; @@ -74,16 +96,22 @@ class MockRenderProcessHost : public RenderProcessHost { TransportDIB* transport_dib_; int bad_msg_count_; const MockRenderProcessHostFactory* factory_; + int id_; + content::BrowserContext* browser_context_; + int32 max_page_id_; + + IDMap<IPC::Channel::Listener> listeners_; + bool fast_shutdown_started_; DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); }; -class MockRenderProcessHostFactory : public RenderProcessHostFactory { +class MockRenderProcessHostFactory : public content::RenderProcessHostFactory { public: MockRenderProcessHostFactory(); virtual ~MockRenderProcessHostFactory(); - virtual RenderProcessHost* CreateRenderProcessHost( + virtual content::RenderProcessHost* CreateRenderProcessHost( content::BrowserContext* browser_context) const OVERRIDE; // Removes the given MockRenderProcessHost from the MockRenderProcessHost list diff --git a/content/browser/renderer_host/pepper_file_message_filter.cc b/content/browser/renderer_host/pepper_file_message_filter.cc index 5c84a8c..9e437e5 100644 --- a/content/browser/renderer_host/pepper_file_message_filter.cc +++ b/content/browser/renderer_host/pepper_file_message_filter.cc @@ -11,7 +11,7 @@ #include "base/process_util.h" #include "content/browser/browser_context.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/common/pepper_file_messages.h" #include "content/public/browser/browser_thread.h" #include "ipc/ipc_platform_file.h" diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc index d916511..4aa1c47 100644 --- a/content/browser/renderer_host/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper_message_filter.cc @@ -21,8 +21,8 @@ #include "base/threading/worker_pool.h" #include "base/values.h" #include "content/browser/font_list_async.h" -#include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/resource_context.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/common/pepper_messages.h" #include "content/public/browser/browser_thread.h" #include "net/base/address_list.h" diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 41ee2cf..3c08ac0 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -22,8 +22,8 @@ #include "content/browser/plugin_service.h" #include "content/browser/plugin_service_filter.h" #include "content/browser/ppapi_plugin_process_host.h" -#include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/renderer_host/media/media_observer.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_widget_helper.h" #include "content/browser/resource_context.h" diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc deleted file mode 100644 index c405961..0000000 --- a/content/browser/renderer_host/render_process_host.cc +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/renderer_host/render_process_host.h" - -#include "base/command_line.h" -#include "base/lazy_instance.h" -#include "base/rand_util.h" -#include "base/sys_info.h" -#include "content/browser/browser_main.h" -#include "content/browser/child_process_security_policy.h" -#include "content/browser/webui/web_ui_factory.h" -#include "content/common/child_process_info.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/content_browser_client.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" -#include "content/public/common/content_constants.h" -#include "content/public/common/content_switches.h" - -using content::BrowserThread; - -namespace { - -size_t max_renderer_count_override = 0; - -size_t GetMaxRendererProcessCount() { - if (max_renderer_count_override) - return max_renderer_count_override; - - // Defines the maximum number of renderer processes according to the - // amount of installed memory as reported by the OS. The table - // values are calculated by assuming that you want the renderers to - // use half of the installed ram and assuming that each tab uses - // ~40MB, however the curve is not linear but piecewise linear with - // interleaved slopes of 3 and 2. - // If you modify this table you need to adjust browser\browser_uitest.cc - // to match the expected number of processes. - - static const size_t kMaxRenderersByRamTier[] = { - 3, // less than 256MB - 6, // 256MB - 9, // 512MB - 12, // 768MB - 14, // 1024MB - 18, // 1280MB - 20, // 1536MB - 22, // 1792MB - 24, // 2048MB - 26, // 2304MB - 29, // 2560MB - 32, // 2816MB - 35, // 3072MB - 38, // 3328MB - 40 // 3584MB - }; - - static size_t max_count = 0; - if (!max_count) { - size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; - if (memory_tier >= arraysize(kMaxRenderersByRamTier)) - max_count = content::kMaxRendererProcessCount; - else - max_count = kMaxRenderersByRamTier[memory_tier]; - } - return max_count; -} - -// Returns true if the given host is suitable for launching a new view -// associated with the given browser context. -static bool IsSuitableHost(RenderProcessHost* host, - content::BrowserContext* browser_context, - const GURL& site_url) { - if (host->browser_context() != browser_context) - return false; - - if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(host->id()) != - content::WebUIFactory::Get()->HasWebUIScheme(site_url)) - return false; - - return content::GetContentClient()->browser()->IsSuitableHost(host, site_url); -} - -// the global list of all renderer processes -base::LazyInstance<IDMap<RenderProcessHost>, - base::LeakyLazyInstanceTraits<IDMap<RenderProcessHost> > > - g_all_hosts = LAZY_INSTANCE_INITIALIZER; - -} // namespace - -// static -bool RenderProcessHost::run_renderer_in_process_ = false; - -// static -void RenderProcessHost::SetMaxRendererProcessCountForTest(size_t count) { - max_renderer_count_override = count; -} - -RenderProcessHost::RenderProcessHost(content::BrowserContext* browser_context) - : max_page_id_(-1), - fast_shutdown_started_(false), - deleting_soon_(false), - pending_views_(0), - id_(ChildProcessInfo::GenerateChildProcessUniqueId()), - browser_context_(browser_context), - sudden_termination_allowed_(true), - ignore_input_events_(false) { - CHECK(!content::ExitedMainMessageLoop()); - g_all_hosts.Get().AddWithID(this, id()); - g_all_hosts.Get().set_check_on_null_data(true); - // Initialize |child_process_activity_time_| to a reasonable value. - mark_child_process_activity_time(); -} - -RenderProcessHost::~RenderProcessHost() { - // In unit tests, Release() might not have been called. - if (g_all_hosts.Get().Lookup(id())) - g_all_hosts.Get().Remove(id()); -} - -bool RenderProcessHost::HasConnection() const { - return channel_.get() != NULL; -} - -void RenderProcessHost::Attach(IPC::Channel::Listener* listener, - int routing_id) { - listeners_.AddWithID(listener, routing_id); -} - -void RenderProcessHost::Release(int listener_id) { - DCHECK(listeners_.Lookup(listener_id) != NULL); - listeners_.Remove(listener_id); - - // Make sure that all associated resource requests are stopped. - CancelResourceRequests(listener_id); - -#if defined(OS_WIN) - // Dump the handle table if handle auditing is enabled. - const CommandLine& browser_command_line = - *CommandLine::ForCurrentProcess(); - if (browser_command_line.HasSwitch(switches::kAuditHandles) || - browser_command_line.HasSwitch(switches::kAuditAllHandles)) { - DumpHandles(); - - // We wait to close the channels until the child process has finished - // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. - return; - } -#endif - Cleanup(); -} - -void RenderProcessHost::Cleanup() { - // When no other owners of this object, we can delete ourselves - if (listeners_.IsEmpty()) { - content::NotificationService::current()->Notify( - content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, - content::Source<RenderProcessHost>(this), - content::NotificationService::NoDetails()); - MessageLoop::current()->DeleteSoon(FROM_HERE, this); - deleting_soon_ = true; - // It's important not to wait for the DeleteTask to delete the channel - // proxy. Kill it off now. That way, in case the profile is going away, the - // rest of the objects attached to this RenderProcessHost start going - // away first, since deleting the channel proxy will post a - // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. - channel_.reset(); - - // Remove ourself from the list of renderer processes so that we can't be - // reused in between now and when the Delete task runs. - g_all_hosts.Get().Remove(id()); - } -} - -void RenderProcessHost::ReportExpectingClose(int32 listener_id) { - listeners_expecting_close_.insert(listener_id); -} - -void RenderProcessHost::AddPendingView() { - pending_views_++; -} - -void RenderProcessHost::RemovePendingView() { - DCHECK(pending_views_); - pending_views_--; -} - -void RenderProcessHost::UpdateMaxPageID(int32 page_id) { - if (page_id > max_page_id_) - max_page_id_ = page_id; -} - -bool RenderProcessHost::FastShutdownForPageCount(size_t count) { - if (listeners_.size() == count) - return FastShutdownIfPossible(); - return false; -} - -// static -RenderProcessHost::iterator RenderProcessHost::AllHostsIterator() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return iterator(g_all_hosts.Pointer()); -} - -// static -RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return g_all_hosts.Get().Lookup(render_process_id); -} - -// static -bool RenderProcessHost::ShouldTryToUseExistingProcessHost() { - size_t renderer_process_count = g_all_hosts.Get().size(); - - // NOTE: Sometimes it's necessary to create more render processes than - // GetMaxRendererProcessCount(), for instance when we want to create - // a renderer process for a browser context that has no existing - // renderers. This is OK in moderation, since the - // GetMaxRendererProcessCount() is conservative. - - return run_renderer_in_process() || - (renderer_process_count >= GetMaxRendererProcessCount()); -} - -// static -RenderProcessHost* RenderProcessHost::GetExistingProcessHost( - content::BrowserContext* browser_context, - const GURL& site_url) { - // First figure out which existing renderers we can use. - std::vector<RenderProcessHost*> suitable_renderers; - suitable_renderers.reserve(g_all_hosts.Get().size()); - - iterator iter(AllHostsIterator()); - while (!iter.IsAtEnd()) { - if (run_renderer_in_process() || - IsSuitableHost(iter.GetCurrentValue(), browser_context, site_url)) - suitable_renderers.push_back(iter.GetCurrentValue()); - - iter.Advance(); - } - - // Now pick a random suitable renderer, if we have any. - if (!suitable_renderers.empty()) { - int suitable_count = static_cast<int>(suitable_renderers.size()); - int random_index = base::RandInt(0, suitable_count - 1); - return suitable_renderers[random_index]; - } - - return NULL; -} diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h deleted file mode 100644 index 6003203..0000000 --- a/content/browser/renderer_host/render_process_host.h +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ -#define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ -#pragma once - -#include <set> - -#include "base/id_map.h" -#include "base/memory/scoped_ptr.h" -#include "base/process.h" -#include "base/process_util.h" -#include "base/time.h" -#include "content/common/content_export.h" -#include "ipc/ipc_channel_proxy.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/surface/transport_dib.h" - -class GURL; -struct ViewMsg_SwapOut_Params; - -namespace content { -class BrowserContext; -} - -// Virtual interface that represents the browser side of the browser <-> -// renderer communication channel. There will generally be one -// RenderProcessHost per renderer process. -// -// The concrete implementation of this class for normal use is the -// BrowserRenderProcessHost. It may also be implemented by a testing interface -// for mocking purposes. -class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, - public IPC::Channel::Listener { - public: - typedef IDMap<RenderProcessHost>::iterator iterator; - - // Details for RENDERER_PROCESS_CLOSED notifications. - struct RendererClosedDetails { - RendererClosedDetails(base::ProcessHandle handle, - base::TerminationStatus status, - int exit_code, - bool was_alive) { - this->handle = handle; - this->status = status; - this->exit_code = exit_code; - this->was_alive = was_alive; - } - base::ProcessHandle handle; - base::TerminationStatus status; - int exit_code; - bool was_alive; - }; - - explicit RenderProcessHost(content::BrowserContext* browser_context); - virtual ~RenderProcessHost(); - - // Returns the user browser context associated with this renderer process. - content::BrowserContext* browser_context() const { return browser_context_; } - - // Returns the unique ID for this child process. This can be used later in - // a call to FromID() to get back to this object (this is used to avoid - // sending non-threadsafe pointers to other threads). - // - // This ID will be unique for all child processes, including workers, plugins, - // etc. It is generated by ChildProcessInfo. - int id() const { return id_; } - - // Returns true iff channel_ has been set to non-NULL. Use this for checking - // if there is connection or not. Virtual for mocking out for tests. - virtual bool HasConnection() const; - - bool sudden_termination_allowed() const { - return sudden_termination_allowed_; - } - void set_sudden_termination_allowed(bool enabled) { - sudden_termination_allowed_ = enabled; - } - - // Used for refcounting, each holder of this object must Attach and Release - // just like it would for a COM object. This object should be allocated on - // the heap; when no listeners own it any more, it will delete itself. - void Attach(IPC::Channel::Listener* listener, int routing_id); - - // See Attach() - void Release(int listener_id); - - // Schedules the host for deletion and removes it from the all_hosts list. - void Cleanup(); - - // Listeners should call this when they've sent a "Close" message and - // they're waiting for a "Close_ACK", so that if the renderer process - // goes away we'll know that it was intentional rather than a crash. - void ReportExpectingClose(int32 listener_id); - - // Track the count of pending views that are being swapped back in. Called - // by listeners to register and unregister pending views to prevent the - // process from exiting. - void AddPendingView(); - void RemovePendingView(); - - // Allows iteration over this RenderProcessHost's RenderViewHost listeners. - // Use from UI thread only. - typedef IDMap<IPC::Channel::Listener>::const_iterator listeners_iterator; - - listeners_iterator ListenersIterator() { - return listeners_iterator(&listeners_); - } - - IPC::Channel::Listener* GetListenerByID(int routing_id) { - return listeners_.Lookup(routing_id); - } - - IPC::ChannelProxy* channel() { return channel_.get(); } - - // Called to inform the render process host of a new "max page id" for a - // render view host. The render process host computes the largest page id - // across all render view hosts and uses the value when it needs to - // initialize a new renderer in place of the current one. - void UpdateMaxPageID(int32 page_id); - - void set_ignore_input_events(bool ignore_input_events) { - ignore_input_events_ = ignore_input_events; - } - bool ignore_input_events() { - return ignore_input_events_; - } - - // Returns how long the child has been idle. The definition of idle - // depends on when a derived class calls mark_child_process_activity_time(). - // This is a rough indicator and its resolution should not be better than - // 10 milliseconds. - base::TimeDelta get_child_process_idle_time() const { - return base::TimeTicks::Now() - child_process_activity_time_; - } - - // Call this function when it is evident that the child process is actively - // performing some operation, for example if we just received an IPC message. - void mark_child_process_activity_time() { - child_process_activity_time_ = base::TimeTicks::Now(); - } - - // Try to shutdown the associated render process as fast as possible, but - // only if |count| matches the number of render widgets that this process - // controls. - bool FastShutdownForPageCount(size_t count); - - bool fast_shutdown_started() { - return fast_shutdown_started_; - } - - // Virtual interface --------------------------------------------------------- - - // Call this to allow queueing of IPC messages that are sent before the - // process is launched. - virtual void EnableSendQueue() = 0; - - // Initialize the new renderer process, returning true on success. This must - // be called once before the object can be used, but can be called after - // that with no effect. Therefore, if the caller isn't sure about whether - // the process has been created, it should just call Init(). - virtual bool Init(bool is_accessibility_enabled) = 0; - - // Gets the next available routing id. - virtual int GetNextRoutingID() = 0; - - // Update the max page ID and send the update to the renderer process as well. - virtual void UpdateAndSendMaxPageID(int32 page_id) = 0; - - // Called on the UI thread to cancel any outstanding resource requests for - // the specified render widget. - virtual void CancelResourceRequests(int render_widget_id) = 0; - - // Called on the UI thread to simulate a SwapOut_ACK message to the - // ResourceDispatcherHost. Necessary for a cross-site request, in the case - // that the original RenderViewHost is not live and thus cannot run an - // unload handler. - virtual void CrossSiteSwapOutACK( - const ViewMsg_SwapOut_Params& params) = 0; - - // Called on the UI thread to wait for the next UpdateRect message for the - // specified render widget. Returns true if successful, and the msg out- - // param will contain a copy of the received UpdateRect message. - virtual bool WaitForUpdateMsg(int render_widget_id, - const base::TimeDelta& max_delay, - IPC::Message* msg) = 0; - - // Called when a received message cannot be decoded. - virtual void ReceivedBadMessage() = 0; - - // Track the count of visible widgets. Called by listeners to register and - // unregister visibility. - virtual void WidgetRestored() = 0; - virtual void WidgetHidden() = 0; - virtual int VisibleWidgetCount() const = 0; - - // Try to shutdown the associated renderer process as fast as possible. - // If this renderer has any RenderViews with unload handlers, then this - // function does nothing. The current implementation uses TerminateProcess. - // Returns True if it was able to do fast shutdown. - virtual bool FastShutdownIfPossible() = 0; - - // Dump the child process' handle table before shutting down. - virtual void DumpHandles() = 0; - - // Returns the process object associated with the child process. In certain - // tests or single-process mode, this will actually represent the current - // process. - // - // NOTE: this is not necessarily valid immediately after calling Init, as - // Init starts the process asynchronously. It's guaranteed to be valid after - // the first IPC arrives. - virtual base::ProcessHandle GetHandle() = 0; - - // Transport DIB functions --------------------------------------------------- - - // Return the TransportDIB for the given id. On Linux, this can involve - // mapping shared memory. On Mac, the shared memory is created in the browser - // process and the cached metadata is returned. On Windows, this involves - // duplicating the handle from the remote process. The RenderProcessHost - // still owns the returned DIB. - virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) = 0; - - // RenderWidgetHost / compositing surface mapping functions ------------------ - - // Set a mapping from a RenderWidgetHost to a compositing surface. Pass a null - // handle to remove the mapping. - virtual void SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) = 0; - - // Static management functions ----------------------------------------------- - - // Flag to run the renderer in process. This is primarily - // for debugging purposes. When running "in process", the - // browser maintains a single RenderProcessHost which communicates - // to a RenderProcess which is instantiated in the same process - // with the Browser. All IPC between the Browser and the - // Renderer is the same, it's just not crossing a process boundary. - static bool run_renderer_in_process() { - return run_renderer_in_process_; - } - static void set_run_renderer_in_process(bool value) { - run_renderer_in_process_ = value; - } - - // Allows iteration over all the RenderProcessHosts in the browser. Note - // that each host may not be active, and therefore may have NULL channels. - static iterator AllHostsIterator(); - - // Returns the RenderProcessHost given its ID. Returns NULL if the ID does - // not correspond to a live RenderProcessHost. - static RenderProcessHost* FromID(int render_process_id); - - // Returns true if the caller should attempt to use an existing - // RenderProcessHost rather than creating a new one. - static bool ShouldTryToUseExistingProcessHost(); - - // Get an existing RenderProcessHost associated with the given browser - // context, if possible. The renderer process is chosen randomly from - // suitable renderers that share the same context and type (determined by the - // site url). - // Returns NULL if no suitable renderer process is available, in which case - // the caller is free to create a new renderer. - static RenderProcessHost* GetExistingProcessHost( - content::BrowserContext* browser_context, const GURL& site_url); - - // Overrides the default heuristic for limiting the max renderer process - // count. This is useful for unit testing process limit behaviors. - // A value of zero means to use the default heuristic. - static void SetMaxRendererProcessCountForTest(size_t count); - - protected: - // A proxy for our IPC::Channel that lives on the IO thread (see - // browser_process.h) - scoped_ptr<IPC::ChannelProxy> channel_; - - // The registered listeners. When this list is empty or all NULL, we should - // delete ourselves - IDMap<IPC::Channel::Listener> listeners_; - - // The maximum page ID we've ever seen from the renderer process. - int32 max_page_id_; - - // True if fast shutdown has been performed on this RPH. - bool fast_shutdown_started_; - - // True if we've posted a DeleteTask and will be deleted soon. - bool deleting_soon_; - - // The count of currently swapped out but pending RenderViews. We have - // started to swap these in, so the renderer process should not exit if - // this count is non-zero. - int32 pending_views_; - - private: - // The globally-unique identifier for this RPH. - int id_; - - content::BrowserContext* browser_context_; - - // set of listeners that expect the renderer process to close - std::set<int> listeners_expecting_close_; - - // True if the process can be shut down suddenly. If this is true, then we're - // sure that all the RenderViews in the process can be shutdown suddenly. If - // it's false, then specific RenderViews might still be allowed to be shutdown - // suddenly by checking their SuddenTerminationAllowed() flag. This can occur - // if one tab has an unload event listener but another tab in the same process - // doesn't. - bool sudden_termination_allowed_; - - // Set to true if we shouldn't send input events. We actually do the - // filtering for this at the render widget level. - bool ignore_input_events_; - - // See getter above. - static bool run_renderer_in_process_; - - // Records the last time we regarded the child process active. - base::TimeTicks child_process_activity_time_; - - DISALLOW_COPY_AND_ASSIGN(RenderProcessHost); -}; - -// Factory object for RenderProcessHosts. Using this factory allows tests to -// swap out a different one to use a TestRenderProcessHost. -class RenderProcessHostFactory { - public: - virtual ~RenderProcessHostFactory() {} - virtual RenderProcessHost* CreateRenderProcessHost( - content::BrowserContext* browser_context) const = 0; -}; - -#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_H_ diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index e15f7309..3d25b02 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc @@ -7,7 +7,7 @@ #include "base/command_line.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/test_url_constants.h" #include "content/public/common/content_switches.h" @@ -17,7 +17,8 @@ RenderProcessHostTest::RenderProcessHostTest() { } int RenderProcessHostTest::RenderProcessHostCount() { - RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); + content::RenderProcessHost::iterator hosts = + content::RenderProcessHost::AllHostsIterator(); int count = 0; while (!hosts.IsAtEnd()) { if (hosts.GetCurrentValue()->HasConnection()) @@ -29,7 +30,7 @@ int RenderProcessHostTest::RenderProcessHostCount() { IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { // Set max renderers to 1 to force running out of processes. - RenderProcessHost::SetMaxRendererProcessCountForTest(1); + content::RenderProcessHost::SetMaxRendererProcessCountForTest(1); CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); parsed_command_line.AppendSwitch(switches::kProcessPerTab); @@ -89,15 +90,15 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { // in a process of that type, even if that means creating a new process. IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) { // Set max renderers to 1 to force running out of processes. - RenderProcessHost::SetMaxRendererProcessCountForTest(1); + content::RenderProcessHost::SetMaxRendererProcessCountForTest(1); int tab_count = 1; int host_count = 1; TabContents* tab1 = NULL; TabContents* tab2 = NULL; - RenderProcessHost* rph1 = NULL; - RenderProcessHost* rph2 = NULL; - RenderProcessHost* rph3 = NULL; + content::RenderProcessHost* rph1 = NULL; + content::RenderProcessHost* rph2 = NULL; + content::RenderProcessHost* rph3 = NULL; #if defined(TOUCH_UI) ++host_count; // For the touch keyboard. diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/render_process_host_impl.cc index 3cb6b5c..cd5f9b4b 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -5,7 +5,7 @@ // Represents the browser side of the browser <--> renderer communication // channel. There will be one RenderProcessHost per renderer process. -#include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include <algorithm> #include <limits> @@ -20,18 +20,22 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/command_line.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/platform_file.h" +#include "base/rand_util.h" #include "base/stl_util.h" #include "base/string_util.h" +#include "base/sys_info.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "content/browser/appcache/appcache_dispatcher_host.h" #include "content/browser/browser_child_process_host.h" #include "content/browser/browser_context.h" +#include "content/browser/browser_main.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/device_orientation/message_filter.h" #include "content/browser/download/mhtml_generation_manager.h" @@ -68,6 +72,7 @@ #include "content/browser/speech/speech_input_dispatcher_host.h" #include "content/browser/trace_message_filter.h" #include "content/browser/user_metrics.h" +#include "content/browser/webui/web_ui_factory.h" #include "content/browser/worker_host/worker_message_filter.h" #include "content/common/child_process_info.h" #include "content/common/child_process_messages.h" @@ -77,6 +82,7 @@ #include "content/common/resource_messages.h" #include "content/common/view_messages.h" #include "content/public/browser/content_browser_client.h" +#include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "content/renderer/render_process_impl.h" @@ -183,21 +189,103 @@ class RendererURLRequestContextSelector scoped_refptr<net::URLRequestContextGetter> media_request_context_; }; +size_t max_renderer_count_override = 0; + +size_t GetMaxRendererProcessCount() { + if (max_renderer_count_override) + return max_renderer_count_override; + + // Defines the maximum number of renderer processes according to the + // amount of installed memory as reported by the OS. The table + // values are calculated by assuming that you want the renderers to + // use half of the installed ram and assuming that each tab uses + // ~40MB, however the curve is not linear but piecewise linear with + // interleaved slopes of 3 and 2. + // If you modify this table you need to adjust browser\browser_uitest.cc + // to match the expected number of processes. + + static const size_t kMaxRenderersByRamTier[] = { + 3, // less than 256MB + 6, // 256MB + 9, // 512MB + 12, // 768MB + 14, // 1024MB + 18, // 1280MB + 20, // 1536MB + 22, // 1792MB + 24, // 2048MB + 26, // 2304MB + 29, // 2560MB + 32, // 2816MB + 35, // 3072MB + 38, // 3328MB + 40 // 3584MB + }; + + static size_t max_count = 0; + if (!max_count) { + size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; + if (memory_tier >= arraysize(kMaxRenderersByRamTier)) + max_count = content::kMaxRendererProcessCount; + else + max_count = kMaxRenderersByRamTier[memory_tier]; + } + return max_count; +} + +// Returns true if the given host is suitable for launching a new view +// associated with the given browser context. +static bool IsSuitableHost(content::RenderProcessHost* host, + content::BrowserContext* browser_context, + const GURL& site_url) { + if (host->GetBrowserContext() != browser_context) + return false; + + if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( + host->GetID()) != + content::WebUIFactory::Get()->HasWebUIScheme(site_url)) + return false; + + return content::GetContentClient()->browser()->IsSuitableHost(host, site_url); +} + } // namespace -BrowserRenderProcessHost::BrowserRenderProcessHost( +// the global list of all renderer processes +base::LazyInstance< + IDMap<content::RenderProcessHost>, + base::LeakyLazyInstanceTraits<IDMap<content::RenderProcessHost> > > + g_all_hosts = LAZY_INSTANCE_INITIALIZER; + +// static +bool g_run_renderer_in_process_ = false; + +// static +void content::RenderProcessHost::SetMaxRendererProcessCountForTest( + size_t count) { + max_renderer_count_override = count; +} + +RenderProcessHostImpl::RenderProcessHostImpl( content::BrowserContext* browser_context) - : RenderProcessHost(browser_context), + : max_page_id_(-1), + fast_shutdown_started_(false), + deleting_soon_(false), + pending_views_(0), visible_widgets_(0), backgrounded_(true), ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( FROM_HERE, base::TimeDelta::FromSeconds(5), - this, &BrowserRenderProcessHost::ClearTransportDIBCache)), + this, &RenderProcessHostImpl::ClearTransportDIBCache)), accessibility_enabled_(false), - is_initialized_(false) { + is_initialized_(false), + id_(ChildProcessInfo::GenerateChildProcessUniqueId()), + browser_context_(browser_context), + sudden_termination_allowed_(true), + ignore_input_events_(false) { widget_helper_ = new RenderWidgetHelper(); - ChildProcessSecurityPolicy::GetInstance()->Add(id()); + ChildProcessSecurityPolicy::GetInstance()->Add(GetID()); // Grant most file permissions to this renderer. // PLATFORM_FILE_TEMPORARY, PLATFORM_FILE_HIDDEN and @@ -205,7 +293,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost( // requests them. // This is for the filesystem sandbox. ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( - id(), browser_context->GetPath().Append( + GetID(), browser_context->GetPath().Append( fileapi::SandboxMountPointProvider::kNewFileSystemDirectory), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_CREATE | @@ -222,26 +310,31 @@ BrowserRenderProcessHost::BrowserRenderProcessHost( // This is so that we can read and move stuff out of the old filesystem // sandbox. ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( - id(), browser_context->GetPath().Append( + GetID(), browser_context->GetPath().Append( fileapi::SandboxMountPointProvider::kOldFileSystemDirectory), base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE); // This is so that we can rename the old sandbox out of the way so that we // know we've taken care of it. ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( - id(), browser_context->GetPath().Append( + GetID(), browser_context->GetPath().Append( fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory), base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE); - // Note: When we create the BrowserRenderProcessHost, it's technically + CHECK(!content::ExitedMainMessageLoop()); + g_all_hosts.Get().AddWithID(this, GetID()); + g_all_hosts.Get().set_check_on_null_data(true); + // Initialize |child_process_activity_time_| to a reasonable value. + mark_child_process_activity_time(); + // Note: When we create the RenderProcessHostImpl, it's technically // backgrounded, because it has no visible listeners. But the process // doesn't actually exist yet, so we'll Background it later, after // creation. } -BrowserRenderProcessHost::~BrowserRenderProcessHost() { - ChildProcessSecurityPolicy::GetInstance()->Remove(id()); +RenderProcessHostImpl::~RenderProcessHostImpl() { + ChildProcessSecurityPolicy::GetInstance()->Remove(GetID()); // We may have some unsent messages at this point, but that's OK. channel_.reset(); @@ -251,13 +344,15 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() { } ClearTransportDIBCache(); + if (g_all_hosts.Get().Lookup(GetID())) + g_all_hosts.Get().Remove(GetID()); } -void BrowserRenderProcessHost::EnableSendQueue() { +void RenderProcessHostImpl::EnableSendQueue() { is_initialized_ = false; } -bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) { +bool RenderProcessHostImpl::Init(bool is_accessibility_enabled) { // calling Init() more than once does nothing, this makes it more convenient // for the view host which may not be sure in some cases if (channel_.get()) @@ -295,7 +390,8 @@ bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) { BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); // Call the embedder first so that their IPC filters have priority. - content::GetContentClient()->browser()->BrowserRenderProcessHostCreated(this); + content::GetContentClient()->browser()->RenderProcessHostCreated( + this); CreateMessageFilters(); @@ -350,110 +446,115 @@ bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) { return true; } -void BrowserRenderProcessHost::CreateMessageFilters() { +void RenderProcessHostImpl::CreateMessageFilters() { scoped_refptr<RenderMessageFilter> render_message_filter( new RenderMessageFilter( - id(), + GetID(), PluginService::GetInstance(), - browser_context(), - browser_context()->GetRequestContextForRenderProcess(id()), + GetBrowserContext(), + GetBrowserContext()->GetRequestContextForRenderProcess(GetID()), widget_helper_)); channel_->AddFilter(render_message_filter); ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( - id(), ChildProcessInfo::RENDER_PROCESS, - &browser_context()->GetResourceContext(), - new RendererURLRequestContextSelector(browser_context(), id()), + GetID(), ChildProcessInfo::RENDER_PROCESS, + &GetBrowserContext()->GetResourceContext(), + new RendererURLRequestContextSelector(GetBrowserContext(), GetID()), content::GetContentClient()->browser()->GetResourceDispatcherHost()); channel_->AddFilter(resource_message_filter); channel_->AddFilter(new AudioInputRendererHost( - &browser_context()->GetResourceContext())); + &GetBrowserContext()->GetResourceContext())); channel_->AddFilter( - new AudioRendererHost(&browser_context()->GetResourceContext())); + new AudioRendererHost(&GetBrowserContext()->GetResourceContext())); channel_->AddFilter( - new VideoCaptureHost(&browser_context()->GetResourceContext())); + new VideoCaptureHost(&GetBrowserContext()->GetResourceContext())); channel_->AddFilter( - new AppCacheDispatcherHost(browser_context()->GetAppCacheService(), - id())); + new AppCacheDispatcherHost(GetBrowserContext()->GetAppCacheService(), + GetID())); channel_->AddFilter(new ClipboardMessageFilter()); channel_->AddFilter( - new DOMStorageMessageFilter(id(), browser_context()->GetWebKitContext())); + new DOMStorageMessageFilter(GetID(), + GetBrowserContext()->GetWebKitContext())); channel_->AddFilter( - new IndexedDBDispatcherHost(id(), browser_context()->GetWebKitContext())); + new IndexedDBDispatcherHost(GetID(), + GetBrowserContext()->GetWebKitContext())); channel_->AddFilter( GeolocationDispatcherHost::New( - id(), browser_context()->GetGeolocationPermissionContext())); - channel_->AddFilter(new GpuMessageFilter(id(), widget_helper_.get())); + GetID(), GetBrowserContext()->GetGeolocationPermissionContext())); + channel_->AddFilter(new GpuMessageFilter(GetID(), widget_helper_.get())); channel_->AddFilter(new media_stream::MediaStreamDispatcherHost( - &browser_context()->GetResourceContext(), id())); - channel_->AddFilter(new PepperFileMessageFilter(id(), browser_context())); + &GetBrowserContext()->GetResourceContext(), GetID())); + channel_->AddFilter(new PepperFileMessageFilter(GetID(), + GetBrowserContext())); channel_->AddFilter( - new PepperMessageFilter(&browser_context()->GetResourceContext())); + new PepperMessageFilter(&GetBrowserContext()->GetResourceContext())); channel_->AddFilter(new speech_input::SpeechInputDispatcherHost( - id(), browser_context()->GetRequestContext(), - browser_context()->GetSpeechInputPreferences())); + GetID(), GetBrowserContext()->GetRequestContext(), + GetBrowserContext()->GetSpeechInputPreferences())); channel_->AddFilter( - new FileSystemDispatcherHost(browser_context()->GetRequestContext(), - browser_context()->GetFileSystemContext())); + new FileSystemDispatcherHost( + GetBrowserContext()->GetRequestContext(), + GetBrowserContext()->GetFileSystemContext())); channel_->AddFilter(new device_orientation::MessageFilter()); channel_->AddFilter( - new BlobMessageFilter(id(), browser_context()->GetBlobStorageContext())); - channel_->AddFilter(new FileUtilitiesMessageFilter(id())); + new BlobMessageFilter(GetID(), + GetBrowserContext()->GetBlobStorageContext())); + channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); channel_->AddFilter(new MimeRegistryMessageFilter()); channel_->AddFilter(new DatabaseMessageFilter( - browser_context()->GetDatabaseTracker())); + GetBrowserContext()->GetDatabaseTracker())); #if defined(OS_MACOSX) - channel_->AddFilter(new TextInputClientMessageFilter(id())); + channel_->AddFilter(new TextInputClientMessageFilter(GetID())); #endif SocketStreamDispatcherHost* socket_stream_dispatcher_host = new SocketStreamDispatcherHost( - new RendererURLRequestContextSelector(browser_context(), id()), - &browser_context()->GetResourceContext()); + new RendererURLRequestContextSelector(GetBrowserContext(), GetID()), + &GetBrowserContext()->GetResourceContext()); channel_->AddFilter(socket_stream_dispatcher_host); channel_->AddFilter( new WorkerMessageFilter( - id(), - &browser_context()->GetResourceContext(), + GetID(), + &GetBrowserContext()->GetResourceContext(), content::GetContentClient()->browser()->GetResourceDispatcherHost(), base::Bind(&RenderWidgetHelper::GetNextRoutingID, base::Unretained(widget_helper_.get())))); #if defined(ENABLE_P2P_APIS) channel_->AddFilter(new content::P2PSocketDispatcherHost( - &browser_context()->GetResourceContext())); + &GetBrowserContext()->GetResourceContext())); #endif channel_->AddFilter(new TraceMessageFilter()); channel_->AddFilter(new ResolveProxyMsgHelper( - browser_context()->GetRequestContextForRenderProcess(id()))); + GetBrowserContext()->GetRequestContextForRenderProcess(GetID()))); channel_->AddFilter(new QuotaDispatcherHost( - id(), browser_context()->GetQuotaManager(), + GetID(), GetBrowserContext()->GetQuotaManager(), content::GetContentClient()->browser()->CreateQuotaPermissionContext())); } -int BrowserRenderProcessHost::GetNextRoutingID() { +int RenderProcessHostImpl::GetNextRoutingID() { return widget_helper_->GetNextRoutingID(); } -void BrowserRenderProcessHost::UpdateAndSendMaxPageID(int32 page_id) { +void RenderProcessHostImpl::UpdateAndSendMaxPageID(int32 page_id) { if (page_id > max_page_id_) Send(new ViewMsg_SetNextPageID(page_id + 1)); UpdateMaxPageID(page_id); } -void BrowserRenderProcessHost::CancelResourceRequests(int render_widget_id) { +void RenderProcessHostImpl::CancelResourceRequests(int render_widget_id) { widget_helper_->CancelResourceRequests(render_widget_id); } -void BrowserRenderProcessHost::CrossSiteSwapOutACK( +void RenderProcessHostImpl::CrossSiteSwapOutACK( const ViewMsg_SwapOut_Params& params) { widget_helper_->CrossSiteSwapOutACK(params); } -bool BrowserRenderProcessHost::WaitForUpdateMsg( +bool RenderProcessHostImpl::WaitForUpdateMsg( int render_widget_id, const base::TimeDelta& max_delay, IPC::Message* msg) { @@ -465,7 +566,7 @@ bool BrowserRenderProcessHost::WaitForUpdateMsg( return widget_helper_->WaitForUpdateMsg(render_widget_id, max_delay, msg); } -void BrowserRenderProcessHost::ReceivedBadMessage() { +void RenderProcessHostImpl::ReceivedBadMessage() { if (run_renderer_in_process()) { // In single process mode it is better if we don't suicide but just // crash. @@ -476,14 +577,14 @@ void BrowserRenderProcessHost::ReceivedBadMessage() { false); } -void BrowserRenderProcessHost::WidgetRestored() { +void RenderProcessHostImpl::WidgetRestored() { // Verify we were properly backgrounded. DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); visible_widgets_++; SetBackgrounded(false); } -void BrowserRenderProcessHost::WidgetHidden() { +void RenderProcessHostImpl::WidgetHidden() { // On startup, the browser will call Hide if (backgrounded_) return; @@ -497,11 +598,11 @@ void BrowserRenderProcessHost::WidgetHidden() { } } -int BrowserRenderProcessHost::VisibleWidgetCount() const { +int RenderProcessHostImpl::VisibleWidgetCount() const { return visible_widgets_; } -void BrowserRenderProcessHost::AppendRendererCommandLine( +void RenderProcessHostImpl::AppendRendererCommandLine( CommandLine* command_line) const { // Pass the process type first, so it shows first in process listings. command_line->AppendSwitchASCII(switches::kProcessType, @@ -530,7 +631,7 @@ void BrowserRenderProcessHost::AppendRendererCommandLine( } content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( - command_line, id()); + command_line, GetID()); // Appending disable-gpu-feature switches due to software rendering list. GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); @@ -538,7 +639,7 @@ void BrowserRenderProcessHost::AppendRendererCommandLine( gpu_data_manager->AppendRendererCommandLine(command_line); } -void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( +void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( const CommandLine& browser_cmd, CommandLine* renderer_cmd) const { // Propagate the following switches to the renderer command line (along @@ -636,13 +737,13 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( arraysize(kSwitchNames)); // Disable databases in incognito mode. - if (browser_context()->IsOffTheRecord() && + if (GetBrowserContext()->IsOffTheRecord() && !browser_cmd.HasSwitch(switches::kDisableDatabases)) { renderer_cmd->AppendSwitch(switches::kDisableDatabases); } } -base::ProcessHandle BrowserRenderProcessHost::GetHandle() { +base::ProcessHandle RenderProcessHostImpl::GetHandle() { // child_process_launcher_ is null either because we're in single process // mode, we have done fast termination, or the process has crashed. if (run_renderer_in_process() || !child_process_launcher_.get()) @@ -654,7 +755,7 @@ base::ProcessHandle BrowserRenderProcessHost::GetHandle() { return child_process_launcher_->GetHandle(); } -bool BrowserRenderProcessHost::FastShutdownIfPossible() { +bool RenderProcessHostImpl::FastShutdownIfPossible() { if (run_renderer_in_process()) return false; // Single process mode can't do fast shutdown. @@ -671,7 +772,7 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() { // while we're shutting down, so there's a small race here. Given that // the window is small, it's unlikely that the web page has much // state that will be lost by not calling its unload handlers properly. - if (!sudden_termination_allowed()) + if (!SuddenTerminationAllowed()) return false; // Store the handle before it gets changed. @@ -681,7 +782,7 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() { return true; } -void BrowserRenderProcessHost::DumpHandles() { +void RenderProcessHostImpl::DumpHandles() { #if defined(OS_WIN) Send(new ChildProcessMsg_DumpHandles()); return; @@ -691,7 +792,7 @@ void BrowserRenderProcessHost::DumpHandles() { } // This is a platform specific function for mapping a transport DIB given its id -TransportDIB* BrowserRenderProcessHost::MapTransportDIB( +TransportDIB* RenderProcessHostImpl::MapTransportDIB( TransportDIB::Id dib_id) { #if defined(OS_WIN) // On Windows we need to duplicate the handle from the remote process @@ -707,7 +808,7 @@ TransportDIB* BrowserRenderProcessHost::MapTransportDIB( #endif // defined(OS_POSIX) } -TransportDIB* BrowserRenderProcessHost::GetTransportDIB( +TransportDIB* RenderProcessHostImpl::GetTransportDIB( TransportDIB::Id dib_id) { if (!TransportDIB::is_valid_id(dib_id)) return NULL; @@ -745,19 +846,19 @@ TransportDIB* BrowserRenderProcessHost::GetTransportDIB( return dib; } -void BrowserRenderProcessHost::ClearTransportDIBCache() { +void RenderProcessHostImpl::ClearTransportDIBCache() { STLDeleteContainerPairSecondPointers( cached_dibs_.begin(), cached_dibs_.end()); cached_dibs_.clear(); } -void BrowserRenderProcessHost::SetCompositingSurface( +void RenderProcessHostImpl::SetCompositingSurface( int render_widget_id, gfx::PluginWindowHandle compositing_surface) { widget_helper_->SetCompositingSurface(render_widget_id, compositing_surface); } -bool BrowserRenderProcessHost::Send(IPC::Message* msg) { +bool RenderProcessHostImpl::Send(IPC::Message* msg) { if (!channel_.get()) { if (!is_initialized_) { queued_messages_.push(msg); @@ -776,7 +877,7 @@ bool BrowserRenderProcessHost::Send(IPC::Message* msg) { return channel_->Send(msg); } -bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { +bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { // If we're about to be deleted, or have initiated the fast shutdown sequence, // we ignore incoming messages. @@ -787,7 +888,7 @@ bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { if (msg.routing_id() == MSG_ROUTING_CONTROL) { // Dispatch control messages. bool msg_is_ok = true; - IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) + IPC_BEGIN_MESSAGE_MAP_EX(RenderProcessHostImpl, msg, msg_is_ok) IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, OnShutdownRequest) IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, @@ -826,7 +927,7 @@ bool BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { return listener->OnMessageReceived(msg); } -void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { +void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { #if defined(IPC_MESSAGE_LOG_ENABLED) Send(new ChildProcessMsg_SetIPCLoggingEnabled( IPC::Logging::GetInstance()->Enabled())); @@ -837,7 +938,7 @@ void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { Send(new ChildProcessMsg_AskBeforeShutdown()); } -void BrowserRenderProcessHost::OnChannelError() { +void RenderProcessHostImpl::OnChannelError() { if (!channel_.get()) return; @@ -866,7 +967,7 @@ void BrowserRenderProcessHost::OnChannelError() { } // Called when the renderer process handle has been signaled. -void BrowserRenderProcessHost::OnWaitableEventSignaled( +void RenderProcessHostImpl::OnWaitableEventSignaled( base::WaitableEvent* waitable_event) { #if defined (OS_WIN) base::ProcessHandle handle = GetHandle(); @@ -878,7 +979,197 @@ void BrowserRenderProcessHost::OnWaitableEventSignaled( #endif } -void BrowserRenderProcessHost::ProcessDied(base::ProcessHandle handle, +content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { + return browser_context_; +} + +int RenderProcessHostImpl::GetID() const { + return id_; +} + +bool RenderProcessHostImpl::HasConnection() const { + return channel_.get() != NULL; +} + +IPC::Channel::Listener* RenderProcessHostImpl::GetListenerByID( + int routing_id) { + return listeners_.Lookup(routing_id); +} + +void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { + ignore_input_events_ = ignore_input_events; +} + +bool RenderProcessHostImpl::IgnoreInputEvents() const { + return ignore_input_events_; +} + +void RenderProcessHostImpl::Attach(IPC::Channel::Listener* listener, + int routing_id) { + listeners_.AddWithID(listener, routing_id); +} + +void RenderProcessHostImpl::Release(int listener_id) { + DCHECK(listeners_.Lookup(listener_id) != NULL); + listeners_.Remove(listener_id); + + // Make sure that all associated resource requests are stopped. + CancelResourceRequests(listener_id); + +#if defined(OS_WIN) + // Dump the handle table if handle auditing is enabled. + const CommandLine& browser_command_line = + *CommandLine::ForCurrentProcess(); + if (browser_command_line.HasSwitch(switches::kAuditHandles) || + browser_command_line.HasSwitch(switches::kAuditAllHandles)) { + DumpHandles(); + + // We wait to close the channels until the child process has finished + // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. + return; + } +#endif + Cleanup(); +} + +void RenderProcessHostImpl::Cleanup() { + // When no other owners of this object, we can delete ourselves + if (listeners_.IsEmpty()) { + content::NotificationService::current()->Notify( + content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, + content::Source<RenderProcessHost>(this), + content::NotificationService::NoDetails()); + MessageLoop::current()->DeleteSoon(FROM_HERE, this); + deleting_soon_ = true; + // It's important not to wait for the DeleteTask to delete the channel + // proxy. Kill it off now. That way, in case the profile is going away, the + // rest of the objects attached to this RenderProcessHost start going + // away first, since deleting the channel proxy will post a + // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. + channel_.reset(); + + // Remove ourself from the list of renderer processes so that we can't be + // reused in between now and when the Delete task runs. + g_all_hosts.Get().Remove(GetID()); + } +} + +void RenderProcessHostImpl::ReportExpectingClose(int32 listener_id) { + listeners_expecting_close_.insert(listener_id); +} + +void RenderProcessHostImpl::AddPendingView() { + pending_views_++; +} + +void RenderProcessHostImpl::RemovePendingView() { + DCHECK(pending_views_); + pending_views_--; +} + +void RenderProcessHostImpl::UpdateMaxPageID(int32 page_id) { + if (page_id > max_page_id_) + max_page_id_ = page_id; +} + +void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { + sudden_termination_allowed_ = enabled; +} + +bool RenderProcessHostImpl::SuddenTerminationAllowed() const { + return sudden_termination_allowed_; +} + +base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { + return base::TimeTicks::Now() - child_process_activity_time_; +} + +IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() { + return channel_.get(); +} + +content::RenderProcessHost::listeners_iterator + RenderProcessHostImpl::ListenersIterator() { + return listeners_iterator(&listeners_); +} + +bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) { + if (listeners_.size() == count) + return FastShutdownIfPossible(); + return false; +} + +bool RenderProcessHostImpl::FastShutdownStarted() const { + return fast_shutdown_started_; +} + +// static +bool content::RenderProcessHost::run_renderer_in_process() { + return g_run_renderer_in_process_; +} + +void content::RenderProcessHost::set_run_renderer_in_process(bool value) { + g_run_renderer_in_process_ = value; +} + +content::RenderProcessHost::iterator + content::RenderProcessHost::AllHostsIterator() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + return iterator(g_all_hosts.Pointer()); +} + +// static +content::RenderProcessHost* content::RenderProcessHost::FromID( + int render_process_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + return g_all_hosts.Get().Lookup(render_process_id); +} + +// static +bool content::RenderProcessHost::ShouldTryToUseExistingProcessHost() { + size_t renderer_process_count = g_all_hosts.Get().size(); + + // NOTE: Sometimes it's necessary to create more render processes than + // GetMaxRendererProcessCount(), for instance when we want to create + // a renderer process for a browser context that has no existing + // renderers. This is OK in moderation, since the + // GetMaxRendererProcessCount() is conservative. + + return run_renderer_in_process() || + (renderer_process_count >= GetMaxRendererProcessCount()); +} + +// static +content::RenderProcessHost* + content::RenderProcessHost::GetExistingProcessHost( + content::BrowserContext* browser_context, + const GURL& site_url) { + // First figure out which existing renderers we can use. + std::vector<content::RenderProcessHost*> suitable_renderers; + suitable_renderers.reserve(g_all_hosts.Get().size()); + + iterator iter(AllHostsIterator()); + while (!iter.IsAtEnd()) { + if (run_renderer_in_process() || + IsSuitableHost( + iter.GetCurrentValue(), + browser_context, site_url)) + suitable_renderers.push_back(iter.GetCurrentValue()); + + iter.Advance(); + } + + // Now pick a random suitable renderer, if we have any. + if (!suitable_renderers.empty()) { + int suitable_count = static_cast<int>(suitable_renderers.size()); + int random_index = base::RandInt(0, suitable_count - 1); + return suitable_renderers[random_index]; + } + + return NULL; +} + +void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, base::TerminationStatus status, int exit_code, bool was_alive) { @@ -912,7 +1203,7 @@ void BrowserRenderProcessHost::ProcessDied(base::ProcessHandle handle, // TODO(darin): clean this up } -void BrowserRenderProcessHost::OnShutdownRequest() { +void RenderProcessHostImpl::OnShutdownRequest() { // Don't shutdown if there are pending RenderViews being swapped back in. if (pending_views_) return; @@ -927,15 +1218,15 @@ void BrowserRenderProcessHost::OnShutdownRequest() { Send(new ChildProcessMsg_Shutdown()); } -void BrowserRenderProcessHost::OnDumpHandlesDone() { - Cleanup(); +void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { + SetSuddenTerminationAllowed(enabled); } -void BrowserRenderProcessHost::SuddenTerminationChanged(bool enabled) { - set_sudden_termination_allowed(enabled); +void RenderProcessHostImpl::OnDumpHandlesDone() { + Cleanup(); } -void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { +void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) { // Note: we always set the backgrounded_ value. If the process is NULL // (and hence hasn't been created yet), we will set the process priority // later when we create the process. @@ -957,7 +1248,7 @@ void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { child_process_launcher_->SetProcessBackgrounded(backgrounded); } -void BrowserRenderProcessHost::OnProcessLaunched() { +void RenderProcessHostImpl::OnProcessLaunched() { // No point doing anything, since this object will be destructed soon. We // especially don't want to send the RENDERER_PROCESS_CREATED notification, // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to @@ -995,18 +1286,18 @@ void BrowserRenderProcessHost::OnProcessLaunched() { } } -void BrowserRenderProcessHost::OnUserMetricsRecordAction( +void RenderProcessHostImpl::OnUserMetricsRecordAction( const std::string& action) { UserMetrics::RecordComputedAction(action); } -void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { +void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { // Only honor the request if appropriate persmissions are granted. - if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) + if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) content::GetContentClient()->browser()->OpenItem(path); } -void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { +void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> MHTMLGenerated(job_id, data_size); } diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/render_process_host_impl.h index fd023f6..053f5c9b 100644 --- a/content/browser/renderer_host/browser_render_process_host.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ -#define CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ +#ifndef CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_IMPL_H_ +#define CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_IMPL_H_ #pragma once #include <map> @@ -16,7 +16,8 @@ #include "base/timer.h" #include "content/browser/child_process_launcher.h" #include "content/common/content_export.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/public/browser/render_process_host.h" +#include "ipc/ipc_channel_proxy.h" #include "ui/gfx/surface/transport_dib.h" class CommandLine; @@ -41,22 +42,21 @@ class WaitableEvent; // keeps a list of RenderView (renderer) and TabContents (browser) which // are correlated with IDs. This way, the Views and the corresponding ViewHosts // communicate through the two process objects. -class CONTENT_EXPORT BrowserRenderProcessHost - : public RenderProcessHost, +class CONTENT_EXPORT RenderProcessHostImpl + : public content::RenderProcessHost, public ChildProcessLauncher::Client, public base::WaitableEventWatcher::Delegate { public: - explicit BrowserRenderProcessHost(content::BrowserContext* browser_context); - virtual ~BrowserRenderProcessHost(); + explicit RenderProcessHostImpl(content::BrowserContext* browser_context); + virtual ~RenderProcessHostImpl(); // RenderProcessHost implementation (public portion). virtual void EnableSendQueue() OVERRIDE; virtual bool Init(bool is_accessibility_enabled) OVERRIDE; virtual int GetNextRoutingID() OVERRIDE; - virtual void UpdateAndSendMaxPageID(int32 page_id) OVERRIDE; virtual void CancelResourceRequests(int render_widget_id) OVERRIDE; - virtual void CrossSiteSwapOutACK( - const ViewMsg_SwapOut_Params& params) OVERRIDE; + virtual void CrossSiteSwapOutACK(const ViewMsg_SwapOut_Params& params) + OVERRIDE; virtual bool WaitForUpdateMsg(int render_widget_id, const base::TimeDelta& max_delay, IPC::Message* msg) OVERRIDE; @@ -71,6 +71,28 @@ class CONTENT_EXPORT BrowserRenderProcessHost virtual void SetCompositingSurface( int render_widget_id, gfx::PluginWindowHandle compositing_surface) OVERRIDE; + virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; + virtual int GetID() const OVERRIDE; + virtual bool HasConnection() const OVERRIDE; + virtual void UpdateMaxPageID(int32 page_id) OVERRIDE; + virtual IPC::Channel::Listener* GetListenerByID(int routing_id) OVERRIDE; + virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; + virtual bool IgnoreInputEvents() const OVERRIDE; + virtual void Attach(IPC::Channel::Listener* listener, int routing_id) + OVERRIDE; + virtual void Release(int listener_id) OVERRIDE; + virtual void Cleanup() OVERRIDE; + virtual void ReportExpectingClose(int32 listener_id) OVERRIDE; + virtual void AddPendingView() OVERRIDE; + virtual void RemovePendingView() OVERRIDE; + virtual void SetSuddenTerminationAllowed(bool enabled) OVERRIDE; + virtual bool SuddenTerminationAllowed() const OVERRIDE; + virtual IPC::ChannelProxy* GetChannel() OVERRIDE; + virtual listeners_iterator ListenersIterator() OVERRIDE; + virtual bool FastShutdownForPageCount(size_t count) OVERRIDE; + virtual bool FastShutdownStarted() const OVERRIDE; + virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE; + virtual void UpdateAndSendMaxPageID(int32 page_id) OVERRIDE; // IPC::Channel::Sender via RenderProcessHost. virtual bool Send(IPC::Message* msg) OVERRIDE; @@ -87,6 +109,35 @@ class CONTENT_EXPORT BrowserRenderProcessHost virtual void OnWaitableEventSignaled( base::WaitableEvent* waitable_event) OVERRIDE; + // Call this function when it is evident that the child process is actively + // performing some operation, for example if we just received an IPC message. + void mark_child_process_activity_time() { + child_process_activity_time_ = base::TimeTicks::Now(); + } + + protected: + // A proxy for our IPC::Channel that lives on the IO thread (see + // browser_process.h) + scoped_ptr<IPC::ChannelProxy> channel_; + + // The registered listeners. When this list is empty or all NULL, we should + // delete ourselves + IDMap<IPC::Channel::Listener> listeners_; + + // The maximum page ID we've ever seen from the renderer process. + int32 max_page_id_; + + // True if fast shutdown has been performed on this RPH. + bool fast_shutdown_started_; + + // True if we've posted a DeleteTask and will be deleted soon. + bool deleting_soon_; + + // The count of currently swapped out but pending RenderViews. We have + // started to swap these in, so the renderer process should not exit if + // this count is non-zero. + int32 pending_views_; + private: friend class VisitRelayingRenderProcessHost; @@ -135,6 +186,7 @@ class CONTENT_EXPORT BrowserRenderProcessHost // A map of transport DIB ids to cached TransportDIBs std::map<TransportDIB::Id, TransportDIB*> cached_dibs_; + enum { // This is the maximum size of |cached_dibs_| MAX_MAPPED_TRANSPORT_DIBS = 3, @@ -145,7 +197,7 @@ class CONTENT_EXPORT BrowserRenderProcessHost void ClearTransportDIBCache(); // This is used to clear our cache five seconds after the last use. - base::DelayTimer<BrowserRenderProcessHost> cached_dibs_cleaner_; + base::DelayTimer<RenderProcessHostImpl> cached_dibs_cleaner_; // Used in single-process mode. scoped_ptr<RendererMainThread> in_process_renderer_; @@ -171,7 +223,30 @@ class CONTENT_EXPORT BrowserRenderProcessHost base::WaitableEventWatcher child_process_watcher_; #endif - DISALLOW_COPY_AND_ASSIGN(BrowserRenderProcessHost); + // The globally-unique identifier for this RPH. + int id_; + + content::BrowserContext* browser_context_; + + // set of listeners that expect the renderer process to close + std::set<int> listeners_expecting_close_; + + // True if the process can be shut down suddenly. If this is true, then we're + // sure that all the RenderViews in the process can be shutdown suddenly. If + // it's false, then specific RenderViews might still be allowed to be shutdown + // suddenly by checking their SuddenTerminationAllowed() flag. This can occur + // if one tab has an unload event listener but another tab in the same process + // doesn't. + bool sudden_termination_allowed_; + + // Set to true if we shouldn't send input events. We actually do the + // filtering for this at the render widget level. + bool ignore_input_events_; + + // Records the last time we regarded the child process active. + base::TimeTicks child_process_activity_time_; + + DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); }; -#endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_H_ +#endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_RENDER_PROCESS_HOST_IMPL_H_ diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index dd1ebc0..a0edc68 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -23,7 +23,7 @@ #include "content/browser/host_zoom_map.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/power_save_blocker.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_view_host_observer.h" #include "content/browser/renderer_host/render_widget_host.h" @@ -88,7 +88,8 @@ base::i18n::TextDirection WebTextDirectionToChromeTextDirection( // static RenderViewHost* RenderViewHost::FromID(int render_process_id, int render_view_id) { - RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); + content::RenderProcessHost* process = + content::RenderProcessHost::FromID(render_process_id); if (!process) return NULL; RenderWidgetHost* widget = static_cast<RenderWidgetHost*>( @@ -122,7 +123,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { if (!session_storage_namespace_) { session_storage_namespace_ = new SessionStorageNamespace( - process()->browser_context()->GetWebKitContext()); + process()->GetBrowserContext()->GetWebKitContext()); } DCHECK(instance_); @@ -153,7 +154,7 @@ RenderViewHost::~RenderViewHost() { // Be sure to clean up any leftover state from cross-site requests. CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( - process()->id(), routing_id(), false); + process()->GetID(), routing_id(), false); } bool RenderViewHost::CreateRenderView(const string16& frame_name) { @@ -166,7 +167,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { if (!process()->Init(renderer_accessible())) return false; DCHECK(process()->HasConnection()); - DCHECK(process()->browser_context()); + DCHECK(process()->GetBrowserContext()); renderer_initialized_ = true; @@ -176,7 +177,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { ViewMsg_New_Params params; params.parent_window = GetNativeViewId(); params.renderer_preferences = - delegate_->GetRendererPrefs(process()->browser_context()); + delegate_->GetRendererPrefs(process()->GetBrowserContext()); params.web_preferences = delegate_->GetWebkitPrefs(); params.view_id = routing_id(); params.session_storage_namespace_id = session_storage_namespace_->id(); @@ -202,12 +203,12 @@ bool RenderViewHost::IsRenderViewLive() const { void RenderViewHost::SyncRendererPrefs() { Send(new ViewMsg_SetRendererPrefs(routing_id(), delegate_->GetRendererPrefs( - process()->browser_context()))); + process()->GetBrowserContext()))); } void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( - process()->id(), params.url); + process()->GetID(), params.url); ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params); @@ -330,7 +331,7 @@ void RenderViewHost::SwapOut(int new_render_process_host_id, StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); ViewMsg_SwapOut_Params params; - params.closing_process_id = process()->id(); + params.closing_process_id = process()->GetID(); params.closing_route_id = routing_id(); params.new_render_process_host_id = new_render_process_host_id; params.new_request_id = new_request_id; @@ -392,7 +393,7 @@ void RenderViewHost::ClosePageIgnoringUnloadEvents() { void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id) { CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( - process()->id(), routing_id(), has_pending_request); + process()->GetID(), routing_id(), has_pending_request); pending_request_id_ = request_id; } @@ -408,17 +409,17 @@ void RenderViewHost::DragTargetDragEnter( // Grant the renderer the ability to load the drop_data. ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); - policy->GrantRequestURL(process()->id(), drop_data.url); + policy->GrantRequestURL(process()->GetID(), drop_data.url); for (std::vector<string16>::const_iterator iter(drop_data.filenames.begin()); iter != drop_data.filenames.end(); ++iter) { FilePath path = FilePath::FromWStringHack(UTF16ToWideHack(*iter)); - policy->GrantRequestURL(process()->id(), + policy->GrantRequestURL(process()->GetID(), net::FilePathToFileURL(path)); - policy->GrantReadFile(process()->id(), path); + policy->GrantReadFile(process()->GetID(), path); // Allow dragged directories to be enumerated by the child process. // Note that we can't tell a file from a directory at this point. - policy->GrantReadDirectory(process()->id(), path); + policy->GrantReadDirectory(process()->GetID(), path); } Send(new DragMsg_TargetDragEnter(routing_id(), drop_data, client_pt, screen_pt, operations_allowed)); @@ -521,7 +522,7 @@ Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath, void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg, bool success, const string16& user_input) { - process()->set_ignore_input_events(false); + process()->SetIgnoreInputEvents(false); bool is_waiting = is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; if (is_waiting) @@ -567,7 +568,7 @@ void RenderViewHost::DragSourceSystemDragEnded() { void RenderViewHost::AllowBindings(int bindings_flags) { if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) { ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( - process()->id()); + process()->GetID()); } enabled_bindings_ |= bindings_flags; @@ -610,7 +611,7 @@ void RenderViewHost::FilesSelectedInChooser( for (std::vector<FilePath>::const_iterator file = files.begin(); file != files.end(); ++file) { ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( - process()->id(), *file, permissions); + process()->GetID(), *file, permissions); } Send(new ViewMsg_RunFileChooserResponse(routing_id(), files)); } @@ -622,7 +623,7 @@ void RenderViewHost::DirectoryEnumerationFinished( for (std::vector<FilePath>::const_iterator file = files.begin(); file != files.end(); ++file) { ChildProcessSecurityPolicy::GetInstance()->GrantReadFile( - process()->id(), *file); + process()->GetID(), *file); } Send(new ViewMsg_EnumerateDirectoryResponse(routing_id(), request_id, @@ -637,7 +638,7 @@ void RenderViewHost::LoadStateChanged(const GURL& url, } bool RenderViewHost::SuddenTerminationAllowed() const { - return sudden_termination_allowed_ || process()->sudden_termination_allowed(); + return sudden_termination_allowed_ || process()->SuddenTerminationAllowed(); } /////////////////////////////////////////////////////////////////////////////// @@ -883,7 +884,7 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { if (is_waiting_for_unload_ack_) return; - const int renderer_id = process()->id(); + const int renderer_id = process()->GetID(); ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); // Without this check, an evil renderer can trick the browser into creating @@ -985,7 +986,7 @@ void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { // Validate the URLs in |params|. If the renderer can't request the URLs // directly, don't show them in the context menu. ContextMenuParams validated_params(params); - int renderer_id = process()->id(); + int renderer_id = process()->GetID(); ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); @@ -1010,7 +1011,7 @@ void RenderViewHost::OnMsgOpenURL(const GURL& url, int64 source_frame_id) { GURL validated_url(url); FilterURL(ChildProcessSecurityPolicy::GetInstance(), - process()->id(), &validated_url); + process()->GetID(), &validated_url); delegate_->RequestOpenURL( validated_url, referrer, disposition, source_frame_id); @@ -1058,7 +1059,7 @@ void RenderViewHost::OnMsgRunJavaScriptMessage( IPC::Message* reply_msg) { // While a JS message dialog is showing, tabs in the same process shouldn't // process input events. - process()->set_ignore_input_events(true); + process()->SetIgnoreInputEvents(true); StopHangMonitorTimeout(); delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url, flags, reply_msg, @@ -1070,7 +1071,7 @@ void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, IPC::Message* reply_msg) { // While a JS before unload dialog is showing, tabs in the same process // shouldn't process input events. - process()->set_ignore_input_events(true); + process()->SetIgnoreInputEvents(true); StopHangMonitorTimeout(); delegate_->RunBeforeUnloadConfirm(this, message, reply_msg); } @@ -1092,8 +1093,8 @@ void RenderViewHost::OnMsgStartDragging( // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar. if (!drag_url.SchemeIs(chrome::kJavaScriptScheme)) - FilterURL(policy, process()->id(), &drag_url); - FilterURL(policy, process()->id(), &html_base_url); + FilterURL(policy, process()->GetID(), &drag_url); + FilterURL(policy, process()->GetID(), &html_base_url); if (drag_url != drop_data.url || html_base_url != drop_data.html_base_url) { WebDropData drop_data_copy = drop_data; @@ -1410,14 +1411,16 @@ void RenderViewHost::OnDidZoomURL(double zoom_level, bool remember, const GURL& url) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - HostZoomMap* host_zoom_map = process()->browser_context()->GetHostZoomMap(); + HostZoomMap* host_zoom_map = process()->GetBrowserContext()-> + GetHostZoomMap(); if (remember) { host_zoom_map->SetZoomLevel(net::GetHostOrSpecFromURL(url), zoom_level); // Notify renderers from this browser context. - for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); + for (content::RenderProcessHost::iterator i( + content::RenderProcessHost::AllHostsIterator()); !i.IsAtEnd(); i.Advance()) { - RenderProcessHost* render_process_host = i.GetCurrentValue(); - if (render_process_host->browser_context()->GetHostZoomMap()-> + content::RenderProcessHost* render_process_host = i.GetCurrentValue(); + if (render_process_host->GetBrowserContext()->GetHostZoomMap()-> GetOriginal() == host_zoom_map) { render_process_host->Send( new ViewMsg_SetZoomLevelForCurrentURL(url, zoom_level)); @@ -1425,7 +1428,7 @@ void RenderViewHost::OnDidZoomURL(double zoom_level, } } else { host_zoom_map->SetTemporaryZoomLevel( - process()->id(), routing_id(), zoom_level); + process()->GetID(), routing_id(), zoom_level); } } @@ -1454,7 +1457,7 @@ void RenderViewHost::OnMediaNotification(int64 player_cookie, void RenderViewHost::OnRequestDesktopNotificationPermission( const GURL& source_origin, int callback_context) { content::GetContentClient()->browser()->RequestDesktopNotificationPermission( - source_origin, callback_context, process()->id(), routing_id()); + source_origin, callback_context, process()->GetID(), routing_id()); } void RenderViewHost::OnShowDesktopNotification( @@ -1469,12 +1472,12 @@ void RenderViewHost::OnShowDesktopNotification( } content::GetContentClient()->browser()->ShowDesktopNotification( - params, process()->id(), routing_id(), false); + params, process()->GetID(), routing_id(), false); } void RenderViewHost::OnCancelDesktopNotification(int notification_id) { content::GetContentClient()->browser()->CancelDesktopNotification( - process()->id(), routing_id(), notification_id); + process()->GetID(), routing_id(), notification_id); } #if defined(OS_MACOSX) diff --git a/content/browser/renderer_host/render_widget_fullscreen_host.cc b/content/browser/renderer_host/render_widget_fullscreen_host.cc index 4fbd140..ecadaf7 100644 --- a/content/browser/renderer_host/render_widget_fullscreen_host.cc +++ b/content/browser/renderer_host/render_widget_fullscreen_host.cc @@ -5,6 +5,6 @@ #include "content/browser/renderer_host/render_widget_fullscreen_host.h" RenderWidgetFullscreenHost::RenderWidgetFullscreenHost( - RenderProcessHost* process, int routing_id) + content::RenderProcessHost* process, int routing_id) : RenderWidgetHost(process, routing_id) { } diff --git a/content/browser/renderer_host/render_widget_fullscreen_host.h b/content/browser/renderer_host/render_widget_fullscreen_host.h index 63b7070..7904e07 100644 --- a/content/browser/renderer_host/render_widget_fullscreen_host.h +++ b/content/browser/renderer_host/render_widget_fullscreen_host.h @@ -10,7 +10,8 @@ class CONTENT_EXPORT RenderWidgetFullscreenHost : public RenderWidgetHost { public: - RenderWidgetFullscreenHost(RenderProcessHost* process, int routing_id); + RenderWidgetFullscreenHost(content::RenderProcessHost* process, + int routing_id); }; #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_FULLSCREEN_HOST_H_ diff --git a/content/browser/renderer_host/render_widget_helper.cc b/content/browser/renderer_host/render_widget_helper.cc index b5e5ccd..9228e0f 100644 --- a/content/browser/renderer_host/render_widget_helper.cc +++ b/content/browser/renderer_host/render_widget_helper.cc @@ -7,7 +7,7 @@ #include "base/bind.h" #include "base/eintr_wrapper.h" #include "base/threading/thread.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/common/view_messages.h" @@ -194,7 +194,8 @@ void RenderWidgetHelper::OnDispatchUpdateMsg(UpdateMsgProxy* proxy) { OnDiscardUpdateMsg(proxy); // It is reasonable for the host to no longer exist. - RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); + content::RenderProcessHost* host = + content::RenderProcessHost::FromID(render_process_id_); if (host) host->OnMessageReceived(proxy->message); } diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 323a102..706cc2c 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -16,7 +16,7 @@ #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/backing_store_manager.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_helper.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/user_metrics.h" @@ -76,7 +76,7 @@ bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, /////////////////////////////////////////////////////////////////////////////// // RenderWidgetHost -RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, +RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process, int routing_id) : renderer_initialized_(false), renderer_accessible_(false), @@ -264,7 +264,7 @@ void RenderWidgetHost::WasHidden() { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, - new GpuMsg_VisibilityChanged(routing_id_, process()->id(), false)); + new GpuMsg_VisibilityChanged(routing_id_, process()->GetID(), false)); // Tell the RenderProcessHost we were hidden. process_->WidgetHidden(); @@ -300,7 +300,7 @@ void RenderWidgetHost::WasRestored() { GpuProcessHost::SendOnIO( 0, content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, - new GpuMsg_VisibilityChanged(routing_id_, process()->id(), true)); + new GpuMsg_VisibilityChanged(routing_id_, process()->GetID(), true)); process_->WidgetRestored(); @@ -547,7 +547,7 @@ void RenderWidgetHost::StopHangMonitorTimeout() { void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) { TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardMouseEvent"); - if (ignore_input_events_ || process_->ignore_input_events()) + if (ignore_input_events_ || process_->IgnoreInputEvents()) return; // Avoid spamming the renderer with mouse move events. It is important @@ -582,7 +582,7 @@ void RenderWidgetHost::OnMouseActivate() { void RenderWidgetHost::ForwardWheelEvent( const WebMouseWheelEvent& wheel_event) { TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); - if (ignore_input_events_ || process_->ignore_input_events()) + if (ignore_input_events_ || process_->IgnoreInputEvents()) return; // If there's already a mouse wheel event waiting to be sent to the renderer, @@ -617,7 +617,7 @@ void RenderWidgetHost::ForwardWheelEvent( void RenderWidgetHost::ForwardGestureEvent( const WebKit::WebGestureEvent& gesture_event) { TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); - if (ignore_input_events_ || process_->ignore_input_events()) + if (ignore_input_events_ || process_->IgnoreInputEvents()) return; ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); @@ -626,7 +626,7 @@ void RenderWidgetHost::ForwardGestureEvent( void RenderWidgetHost::ForwardKeyboardEvent( const NativeWebKeyboardEvent& key_event) { TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardKeyboardEvent"); - if (ignore_input_events_ || process_->ignore_input_events()) + if (ignore_input_events_ || process_->IgnoreInputEvents()) return; if (key_event.type == WebKeyboardEvent::Char && @@ -692,7 +692,7 @@ void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, if (!process_->HasConnection()) return; - DCHECK(!process_->ignore_input_events()); + DCHECK(!process_->IgnoreInputEvents()); IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); message->WriteData( @@ -718,7 +718,7 @@ void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, void RenderWidgetHost::ForwardTouchEvent( const WebKit::WebTouchEvent& touch_event) { TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent"); - if (ignore_input_events_ || process_->ignore_input_events()) + if (ignore_input_events_ || process_->IgnoreInputEvents()) return; if (touch_event.type == WebInputEvent::TouchMove && diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index c282cc3..610588a 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -31,7 +31,6 @@ class BackingStore; struct EditCommand; -class RenderProcessHost; class RenderWidgetHostView; class TransportDIB; struct ViewHostMsg_UpdateRect_Params; @@ -41,6 +40,10 @@ namespace base { class TimeTicks; } +namespace content { +class RenderProcessHost; +} + namespace gfx { class Rect; } @@ -144,7 +147,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // routing_id can be MSG_ROUTING_NONE, in which case the next available // routing id is taken from the RenderProcessHost. - RenderWidgetHost(RenderProcessHost* process, int routing_id); + RenderWidgetHost(content::RenderProcessHost* process, int routing_id); virtual ~RenderWidgetHost(); // Gets/Sets the View of this RenderWidgetHost. Can be NULL, e.g. if the @@ -154,7 +157,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, void SetView(RenderWidgetHostView* view); RenderWidgetHostView* view() const { return view_; } - RenderProcessHost* process() const { return process_; } + content::RenderProcessHost* process() const { return process_; } int routing_id() const { return routing_id_; } bool renderer_accessible() { return renderer_accessible_; } @@ -620,7 +623,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // Created during construction but initialized during Init*(). Therefore, it // is guaranteed never to be NULL, but its channel may be NULL if the // renderer crashed, so you must always check that. - RenderProcessHost* process_; + content::RenderProcessHost* process_; // Stores random bits of data for others to associate with this object. PropertyBag property_bag_; diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index a0b5245..d90a4dd 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -145,7 +145,7 @@ class TestView : public TestRenderWidgetHostView { class MockRenderWidgetHost : public RenderWidgetHost { public: - MockRenderWidgetHost(RenderProcessHost* process, int routing_id) + MockRenderWidgetHost(content::RenderProcessHost* process, int routing_id) : RenderWidgetHost(process, routing_id), prehandle_keyboard_event_(false), prehandle_keyboard_event_called_(false), diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index ac2cac7..f44a076 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -27,12 +27,15 @@ #include "ui/gfx/surface/transport_dib.h" class BackingStore; -class RenderProcessHost; class RenderWidgetHost; class WebCursor; struct NativeWebKeyboardEvent; struct ViewHostMsg_AccessibilityNotification_Params; +namespace content { +class RenderProcessHost; +} + namespace gfx { class Rect; class Size; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 6fae1a3..39ddf3d 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -25,7 +25,7 @@ #include "content/browser/plugin_process_host.h" #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" #include "content/browser/renderer_host/backing_store_mac.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #import "content/browser/renderer_host/render_widget_host_view_mac_delegate.h" #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h" @@ -929,7 +929,7 @@ void RenderWidgetHostViewMac::AcknowledgeSwapBuffers( // because |GpuProcessHost::Get()| can only be called there. // Currently, this is never called for plugins. if (render_widget_host_) { - DCHECK_EQ(render_widget_host_->process()->id(), renderer_id); + DCHECK_EQ(render_widget_host_->process()->GetID(), renderer_id); // |render_widget_host_->routing_id()| and |route_id| are usually not // equal: The former identifies the channel from the RWH in the browser // process to the corresponding render widget in the renderer process, while diff --git a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm index c81cc83..d053200 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper_unittest.mm @@ -71,7 +71,7 @@ namespace { // Create a RenderWidget for which we can filter messages. class RenderWidgetHostEditCommandCounter : public RenderWidgetHost { public: - RenderWidgetHostEditCommandCounter(RenderProcessHost* process, + RenderWidgetHostEditCommandCounter(content::RenderProcessHost* process, int routing_id) : RenderWidgetHost(process, routing_id), edit_command_message_count_(0) { diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 59257b0..99cf505 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -22,7 +22,7 @@ #include "content/browser/plugin_process_host.h" #include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/backing_store_win.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/common/plugin_messages.h" #include "content/common/view_messages.h" @@ -1911,8 +1911,8 @@ void RenderWidgetHostViewWin::Observe( // Get the RenderProcessHost that posted this notification, and exit // if it's not the one associated with this host view. - RenderProcessHost* render_process_host = - content::Source<RenderProcessHost>(source).ptr(); + content::RenderProcessHost* render_process_host = + content::Source<content::RenderProcessHost>(source).ptr(); DCHECK(render_process_host); if (!render_widget_host_ || render_process_host != render_widget_host_->process()) diff --git a/content/browser/renderer_host/test_backing_store.cc b/content/browser/renderer_host/test_backing_store.cc index f45d35a..4f14eb9 100644 --- a/content/browser/renderer_host/test_backing_store.cc +++ b/content/browser/renderer_host/test_backing_store.cc @@ -13,7 +13,7 @@ TestBackingStore::~TestBackingStore() { } void TestBackingStore::PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/test_backing_store.h b/content/browser/renderer_host/test_backing_store.h index 5dbfa3f..05da4e6 100644 --- a/content/browser/renderer_host/test_backing_store.h +++ b/content/browser/renderer_host/test_backing_store.h @@ -16,7 +16,7 @@ class TestBackingStore : public BackingStore { // BackingStore implementation. virtual void PaintToBackingStore( - RenderProcessHost* process, + content::RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 5bbe3170..abad243 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -258,7 +258,7 @@ void TestRenderWidgetHostView::UnlockMouse() { } TestRenderViewHostFactory::TestRenderViewHostFactory( - RenderProcessHostFactory* rph_factory) + content::RenderProcessHostFactory* rph_factory) : render_process_host_factory_(rph_factory) { RenderViewHostFactory::RegisterFactory(this); } @@ -268,7 +268,7 @@ TestRenderViewHostFactory::~TestRenderViewHostFactory() { } void TestRenderViewHostFactory::set_render_process_host_factory( - RenderProcessHostFactory* rph_factory) { + content::RenderProcessHostFactory* rph_factory) { render_process_host_factory_ = rph_factory; } diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 5a64703..27468dd 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -19,6 +19,7 @@ namespace content { class BrowserContext; +class RenderProcessHostFactory; } namespace gfx { @@ -262,11 +263,12 @@ class TestRenderViewHost : public RenderViewHost { // registered at a time, you can only have one of these objects at a time. class TestRenderViewHostFactory : public RenderViewHostFactory { public: - explicit TestRenderViewHostFactory(RenderProcessHostFactory* rph_factory); + explicit TestRenderViewHostFactory( + content::RenderProcessHostFactory* rph_factory); virtual ~TestRenderViewHostFactory(); virtual void set_render_process_host_factory( - RenderProcessHostFactory* rph_factory); + content::RenderProcessHostFactory* rph_factory); virtual RenderViewHost* CreateRenderViewHost( SiteInstance* instance, RenderViewHostDelegate* delegate, @@ -281,7 +283,7 @@ class TestRenderViewHostFactory : public RenderViewHostFactory { // Instead, we set it right before we create a new RenderViewHost, which // happens before the RenderProcessHost is created. This way, the instance // has the correct factory and creates our special RenderProcessHosts. - RenderProcessHostFactory* render_process_host_factory_; + content::RenderProcessHostFactory* render_process_host_factory_; DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); }; diff --git a/content/browser/renderer_host/text_input_client_mac_unittest.mm b/content/browser/renderer_host/text_input_client_mac_unittest.mm index 58552d6..d3dd7be 100644 --- a/content/browser/renderer_host/text_input_client_mac_unittest.mm +++ b/content/browser/renderer_host/text_input_client_mac_unittest.mm @@ -9,7 +9,7 @@ #include "base/threading/thread.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/renderer_host/mock_render_process_host.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/text_input_client_message_filter.h" #include "content/common/text_input_client_messages.h" @@ -129,7 +129,7 @@ TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) { base::Unretained(service()), kPreviousValue)); scoped_refptr<TextInputClientMessageFilter> filter( - new TextInputClientMessageFilter(widget()->process()->id())); + new TextInputClientMessageFilter(widget()->process()->GetID())); scoped_ptr<IPC::Message> message( new TextInputClientReplyMsg_GotCharacterIndexForPoint( widget()->routing_id(), kNotFoundValue)); diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc index 4cb5759..50672ef 100644 --- a/content/browser/site_instance.cc +++ b/content/browser/site_instance.cc @@ -5,11 +5,12 @@ #include "content/browser/site_instance.h" #include "content/browser/browsing_instance.h" -#include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/webui/web_ui_factory.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host_factory.h" #include "content/public/common/url_constants.h" #include "net/base/registry_controlled_domain.h" @@ -55,7 +56,7 @@ bool SiteInstance::HasProcess() const { return (process_ != NULL); } -RenderProcessHost* SiteInstance::GetProcess() { +content::RenderProcessHost* SiteInstance::GetProcess() { // TODO(erikkay) It would be nice to ensure that the renderer type had been // properly set before we get here. The default tab creation case winds up // with no site set at this point, so it will default to TYPE_NORMAL. This @@ -66,8 +67,8 @@ RenderProcessHost* SiteInstance::GetProcess() { // Create a new process if ours went away or was reused. if (!process_) { // See if we should reuse an old process - if (RenderProcessHost::ShouldTryToUseExistingProcessHost()) - process_ = RenderProcessHost::GetExistingProcessHost( + if (content::RenderProcessHost::ShouldTryToUseExistingProcessHost()) + process_ = content::RenderProcessHost::GetExistingProcessHost( browsing_instance_->browser_context(), site_); // Otherwise (or if that fails), create a new one. @@ -77,7 +78,7 @@ RenderProcessHost* SiteInstance::GetProcess() { browsing_instance_->browser_context()); } else { process_ = - new BrowserRenderProcessHost(browsing_instance_->browser_context()); + new RenderProcessHostImpl(browsing_instance_->browser_context()); } } @@ -224,7 +225,8 @@ void SiteInstance::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); - RenderProcessHost* rph = content::Source<RenderProcessHost>(source).ptr(); + content::RenderProcessHost* rph = + content::Source<content::RenderProcessHost>(source).ptr(); if (rph == process_) process_ = NULL; } diff --git a/content/browser/site_instance.h b/content/browser/site_instance.h index 7bf15f5..057ed59 100644 --- a/content/browser/site_instance.h +++ b/content/browser/site_instance.h @@ -6,7 +6,7 @@ #define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ #pragma once -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/common/content_export.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -16,6 +16,7 @@ class BrowsingInstance; namespace content { class BrowserContext; +class RenderProcessHostFactory; } /////////////////////////////////////////////////////////////////////////////// @@ -67,7 +68,8 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, // The factory must outlive the SiteInstance; ownership is not transferred. It // may be NULL, in which case the default BrowserRenderProcessHost will be // created (this is the behavior if you don't call this function). - void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { + void set_render_process_host_factory( + content::RenderProcessHostFactory* rph_factory) { render_process_host_factory_ = rph_factory; } @@ -84,7 +86,7 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, // Returns the current process being used to render pages in this // SiteInstance. If the process has crashed or otherwise gone away, then // this method will create a new process and update our host ID accordingly. - RenderProcessHost* GetProcess(); + content::RenderProcessHost* GetProcess(); // Set / Get the web site that this SiteInstance is rendering pages for. // This includes the scheme and registered domain, but not the port. If the @@ -183,13 +185,13 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes // that the default BrowserRenderProcessHost should be created. - const RenderProcessHostFactory* render_process_host_factory_; + const content::RenderProcessHostFactory* render_process_host_factory_; // Current RenderProcessHost that is rendering pages for this SiteInstance. // This pointer will only change once the RenderProcessHost is destructed. It // will still remain the same even if the process crashes, since in that // scenario the RenderProcessHost remains the same. - RenderProcessHost* process_; + content::RenderProcessHost* process_; // The current max_page_id in the SiteInstance's RenderProcessHost. If the // rendering process dies, its replacement should start issuing page IDs that diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc index 4559d8b..5763e2c 100644 --- a/content/browser/site_instance_unittest.cc +++ b/content/browser/site_instance_unittest.cc @@ -9,7 +9,7 @@ #include "content/browser/browsing_instance.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/mock_content_browser_client.h" -#include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/site_instance.h" @@ -68,9 +68,9 @@ class SiteInstanceTestBrowserClient : public content::MockContentBrowserClient { url == GURL(chrome::kAboutCrashURL); } - virtual bool IsSuitableHost(RenderProcessHost* process_host, + virtual bool IsSuitableHost(content::RenderProcessHost* process_host, const GURL& site_url) OVERRIDE { - return (privileged_process_id_ == process_host->id()) == + return (privileged_process_id_ == process_host->GetID()) == site_url.SchemeIs(kPrivilegedScheme); } @@ -295,7 +295,7 @@ TEST_F(SiteInstanceTest, UpdateMaxPageID) { TEST_F(SiteInstanceTest, GetProcess) { // Ensure that GetProcess returns a process. scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); - scoped_ptr<RenderProcessHost> host1; + scoped_ptr<content::RenderProcessHost> host1; scoped_refptr<SiteInstance> instance( SiteInstance::CreateSiteInstance(browser_context.get())); host1.reset(instance->GetProcess()); @@ -304,7 +304,7 @@ TEST_F(SiteInstanceTest, GetProcess) { // Ensure that GetProcess creates a new process. scoped_refptr<SiteInstance> instance2( SiteInstance::CreateSiteInstance(browser_context.get())); - scoped_ptr<RenderProcessHost> host2(instance2->GetProcess()); + scoped_ptr<content::RenderProcessHost> host2(instance2->GetProcess()); EXPECT_TRUE(host2.get() != NULL); EXPECT_NE(host1.get(), host2.get()); } @@ -514,8 +514,8 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) { // browsing_instances will be deleted when their SiteInstances are deleted } -static SiteInstance* CreateSiteInstance(RenderProcessHostFactory* factory, - const GURL& url) { +static SiteInstance* CreateSiteInstance( + content::RenderProcessHostFactory* factory, const GURL& url) { SiteInstance* instance = SiteInstance::CreateSiteInstanceForURL(NULL, url); instance->set_render_process_host_factory(factory); return instance; @@ -537,13 +537,13 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { scoped_refptr<SiteInstance> extension1_instance( CreateSiteInstance(&rph_factory, GURL(kPrivilegedScheme + std::string("://foo/bar")))); - SetPrivilegedProcessId(extension1_instance->GetProcess()->id()); + SetPrivilegedProcessId(extension1_instance->GetProcess()->GetID()); scoped_refptr<SiteInstance> extension2_instance( CreateSiteInstance(&rph_factory, GURL(kPrivilegedScheme + std::string("://baz/bar")))); - scoped_ptr<RenderProcessHost> extension_host( + scoped_ptr<content::RenderProcessHost> extension_host( extension1_instance->GetProcess()); EXPECT_EQ(extension1_instance->GetProcess(), extension2_instance->GetProcess()); @@ -551,12 +551,13 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { // Create some WebUI instances and make sure they share a process. scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory, GURL(chrome::kChromeUIScheme + std::string("://newtab")))); - policy->GrantWebUIBindings(webui1_instance->GetProcess()->id()); + policy->GrantWebUIBindings(webui1_instance->GetProcess()->GetID()); scoped_refptr<SiteInstance> webui2_instance( CreateSiteInstance(&rph_factory, GURL(chrome::kChromeUIScheme + std::string("://history")))); - scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess()); + scoped_ptr<content::RenderProcessHost> dom_host( + webui1_instance->GetProcess()); EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess()); // Make sure none of differing privilege processes are mixed. diff --git a/content/browser/ssl/ssl_policy.cc b/content/browser/ssl/ssl_policy.cc index 3b17d950..c6b40c3 100644 --- a/content/browser/ssl/ssl_policy.cc +++ b/content/browser/ssl/ssl_policy.cc @@ -10,7 +10,7 @@ #include "base/memory/singleton.h" #include "base/string_piece.h" #include "base/string_util.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/ssl/ssl_cert_error_handler.h" @@ -93,7 +93,7 @@ void SSLPolicy::DidRunInsecureContent(NavigationEntry* entry, return; backend_->HostRanInsecureContent(GURL(security_origin).host(), - site_instance->GetProcess()->id()); + site_instance->GetProcess()->GetID()); } void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { @@ -145,8 +145,8 @@ void SSLPolicy::UpdateEntry(NavigationEntry* entry, TabContents* tab_contents) { // necessarily have site instances. Without a process, the entry can't // possibly have insecure content. See bug http://crbug.com/12423. if (site_instance && - backend_->DidHostRunInsecureContent(entry->url().host(), - site_instance->GetProcess()->id())) { + backend_->DidHostRunInsecureContent( + entry->url().host(), site_instance->GetProcess()->GetID())) { entry->ssl().set_security_style( content::SECURITY_STYLE_AUTHENTICATION_BROKEN); entry->ssl().set_ran_insecure_content(); diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 112c7c1..957aecd 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -11,7 +11,7 @@ #include "base/string_util.h" #include "base/threading/thread.h" #include "base/utf_string_conversions.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -141,7 +141,7 @@ InterstitialPage::InterstitialPage(TabContents* tab, enabled_(true), action_taken_(NO_ACTION), render_view_host_(NULL), - original_child_id_(tab->render_view_host()->process()->id()), + original_child_id_(tab->render_view_host()->process()->GetID()), original_rvh_id_(tab->render_view_host()->routing_id()), should_revert_tab_title_(false), tab_was_loading_(false), @@ -285,7 +285,7 @@ void InterstitialPage::Observe(int type, // closed); make sure we clear the blocked requests. RenderViewHost* rvh = static_cast<RenderViewHost*>( content::Source<RenderWidgetHost>(source).ptr()); - DCHECK(rvh->process()->id() == original_child_id_ && + DCHECK(rvh->process()->GetID() == original_child_id_ && rvh->routing_id() == original_rvh_id_); TakeActionOnResourceDispatcher(CANCEL); } diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 593933a..5fccef9 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -167,7 +167,7 @@ bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() { // CrossSiteResourceHandler will already be cleaned up.) ViewMsg_SwapOut_Params params; params.new_render_process_host_id = - pending_render_view_host_->process()->id(); + pending_render_view_host_->process()->GetID(); params.new_request_id = pending_request_id; current_host()->process()->CrossSiteSwapOutACK(params); } @@ -194,7 +194,7 @@ void RenderViewHostManager::DidNavigateMainFrame( // then we still need to swap out the old RVH first and run its unload // handler. OK for that to happen in the background. if (pending_render_view_host_->GetPendingRequestId() == -1) { - OnCrossSiteResponse(pending_render_view_host_->process()->id(), + OnCrossSiteResponse(pending_render_view_host_->process()->GetID(), pending_render_view_host_->routing_id()); } @@ -231,7 +231,7 @@ void RenderViewHostManager::RendererAbortedProvisionalLoad( } void RenderViewHostManager::RendererProcessClosing( - RenderProcessHost* render_process_host) { + content::RenderProcessHost* render_process_host) { // Remove any swapped out RVHs from this process, so that we don't try to // swap them back in while the process is exiting. Start by finding them, // since there could be more than one. @@ -320,7 +320,8 @@ void RenderViewHostManager::Observe( const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_RENDERER_PROCESS_CLOSING: - RendererProcessClosing(content::Source<RenderProcessHost>(source).ptr()); + RendererProcessClosing( + content::Source<content::RenderProcessHost>(source).ptr()); break; default: diff --git a/content/browser/tab_contents/render_view_host_manager.h b/content/browser/tab_contents/render_view_host_manager.h index 8a35bcb..8a744bc 100644 --- a/content/browser/tab_contents/render_view_host_manager.h +++ b/content/browser/tab_contents/render_view_host_manager.h @@ -237,7 +237,7 @@ class CONTENT_EXPORT RenderViewHostManager // Called when a renderer process is starting to close. We should not // schedule new navigations in its swapped out RenderViewHosts after this. - void RendererProcessClosing(RenderProcessHost* render_process_host); + void RendererProcessClosing(content::RenderProcessHost* render_process_host); // Our delegate, not owned by us. Guaranteed non-NULL. Delegate* delegate_; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 03a6ed4..d926eec 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -22,7 +22,7 @@ #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/load_from_memory_cache_details.h" #include "content/browser/load_notification_details.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -326,7 +326,7 @@ void TabContents::RunFileChooser( delegate()->RunFileChooser(this, params); } -RenderProcessHost* TabContents::GetRenderProcessHost() const { +content::RenderProcessHost* TabContents::GetRenderProcessHost() const { if (render_manager_.current_host()) return render_manager_.current_host()->process(); else @@ -846,7 +846,7 @@ double TabContents::GetZoomLevel() const { double zoom_level; if (temporary_zoom_settings_) { zoom_level = zoom_map->GetTemporaryZoomLevel( - GetRenderProcessHost()->id(), render_view_host()->routing_id()); + GetRenderProcessHost()->GetID(), render_view_host()->routing_id()); } else { GURL url; NavigationEntry* active_entry = controller().GetActiveEntry(); @@ -914,7 +914,7 @@ void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); GURL validated_url(url); render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), - GetRenderProcessHost()->id(), &validated_url); + GetRenderProcessHost()->GetID(), &validated_url); RenderViewHost* rvh = render_manager_.pending_render_view_host() ? @@ -963,7 +963,7 @@ void TabContents::OnDidFailProvisionalLoadWithError( << ", frame_id: " << params.frame_id; GURL validated_url(params.url); render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), - GetRenderProcessHost()->id(), &validated_url); + GetRenderProcessHost()->GetID(), &validated_url); if (net::ERR_ABORTED == params.error_code) { // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. @@ -1045,7 +1045,7 @@ void TabContents::OnDidLoadResourceFromMemoryCache( &cert_id, &cert_status, &security_bits, &connection_status); - LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->id(), + LoadFromMemoryCacheDetails details(url, GetRenderProcessHost()->GetID(), cert_id, cert_status); content::NotificationService::current()->Notify( diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index d64cbaa..1256c30 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -111,7 +111,7 @@ class CONTENT_EXPORT TabContents : public PageNavigator, // Return the currently active RenderProcessHost and RenderViewHost. Each of // these may change over time. - RenderProcessHost* GetRenderProcessHost() const; + content::RenderProcessHost* GetRenderProcessHost() const; RenderViewHost* render_view_host() const { return render_manager_.current_host(); } diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc index 2096194..5febef8 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui.cc @@ -11,7 +11,7 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" @@ -72,7 +72,7 @@ void WebUI::OnWebUISend(const GURL& source_url, const std::string& message, const ListValue& args) { if (!ChildProcessSecurityPolicy::GetInstance()-> - HasWebUIBindings(tab_contents_->GetRenderProcessHost()->id())) { + HasWebUIBindings(tab_contents_->GetRenderProcessHost()->GetID())) { NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; return; } |