diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 20:30:19 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 20:30:19 +0000 |
commit | 7600428cfa774cfd645d503b50a3d9b4ce1780ac (patch) | |
tree | 8e9f84e57e2c303473ca3735c5281e10a4568950 /content | |
parent | 699f8748055aa448acf0e6dc4b59ce914688796d (diff) | |
download | chromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.zip chromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.tar.gz chromium_src-7600428cfa774cfd645d503b50a3d9b4ce1780ac.tar.bz2 |
Revert "Looks like this introduced leaks in sync ui tests. Sigh."
This reverts commit 471e46f5060ce0fd9413b0bc5ffbe78a2e4c7d02.
TBR=mpcomplete@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
12 files changed, 42 insertions, 70 deletions
diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc index 84603af..901097e 100644 --- a/content/browser/content_browser_client.cc +++ b/content/browser/content_browser_client.cc @@ -14,11 +14,6 @@ void ContentBrowserClient::RenderViewHostCreated( RenderViewHost* render_view_host) { } -void ContentBrowserClient::PreCreateRenderView(RenderViewHost* render_view_host, - Profile* profile, - const GURL& url) { -} - void ContentBrowserClient::BrowserRenderProcessHostCreated( BrowserRenderProcessHost* host) { } diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 2de7751..7772188 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -34,14 +34,7 @@ class ContentBrowserClient { // Notifies that a new RenderHostView has been created. virtual void RenderViewHostCreated(RenderViewHost* render_view_host); - // Initialize a RenderViewHost before its CreateRenderView method is called. - virtual void PreCreateRenderView(RenderViewHost* render_view_host, - Profile* profile, - const GURL& url); - - // Notifies that a BrowserRenderProcessHost has been created. This is called - // before the content layer adds its own BrowserMessageFilters, so that the - // embedder's IPC filters have priority. + // Notifies that a BrowserRenderProcessHost has been created. virtual void BrowserRenderProcessHostCreated(BrowserRenderProcessHost* host); // Notifies that a WorkerProcessHost has been created. diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index 5874e57..2bbfadd 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -192,7 +192,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) base::TimeDelta::FromSeconds(5), this, &BrowserRenderProcessHost::ClearTransportDIBCache)), accessibility_enabled_(false), - extension_process_(false) { + is_initialized_(false) { widget_helper_ = new RenderWidgetHelper(); WebCacheManager::GetInstance()->Add(id()); @@ -239,8 +239,7 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() { ClearTransportDIBCache(); } -bool BrowserRenderProcessHost::Init( - bool is_accessibility_enabled, bool is_extensions_process) { +bool BrowserRenderProcessHost::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()) @@ -248,10 +247,6 @@ bool BrowserRenderProcessHost::Init( accessibility_enabled_ = is_accessibility_enabled; - // It is possible for an extension process to be reused for non-extension - // content, e.g. if an extension calls window.open. - extension_process_ = extension_process_ || is_extensions_process; - CommandLine::StringType renderer_prefix; #if defined(OS_POSIX) // A command prefix is something prepended to the command line of the spawned @@ -332,6 +327,7 @@ bool BrowserRenderProcessHost::Init( fast_shutdown_started_ = false; } + is_initialized_ = true; return true; } @@ -470,8 +466,8 @@ void BrowserRenderProcessHost::AppendRendererCommandLine( // Extensions use a special pseudo-process type to make them distinguishable, // even though they're just renderers. command_line->AppendSwitchASCII(switches::kProcessType, - extension_process_ ? switches::kExtensionProcess : - switches::kRendererProcess); + is_extension_process_ ? switches::kExtensionProcess : + switches::kRendererProcess); if (logging::DialogsAreSuppressed()) command_line->AppendSwitch(switches::kNoErrorDialogs); @@ -762,8 +758,13 @@ void BrowserRenderProcessHost::ClearTransportDIBCache() { bool BrowserRenderProcessHost::Send(IPC::Message* msg) { if (!channel_.get()) { - delete msg; - return false; + if (!is_initialized_) { + queued_messages_.push(msg); + return true; + } else { + delete msg; + return false; + } } if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) { @@ -846,15 +847,15 @@ void BrowserRenderProcessHost::OnChannelError() { if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", - extension_process_ ? 2 : 1); + is_extension_process_ ? 2 : 1); } if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", - extension_process_ ? 2 : 1); + is_extension_process_ ? 2 : 1); } - RendererClosedDetails details(status, exit_code, extension_process_); + RendererClosedDetails details(status, exit_code, is_extension_process_); NotificationService::current()->Notify( NotificationType::RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/browser_render_process_host.h index d3eee33..c97648c 100644 --- a/content/browser/renderer_host/browser_render_process_host.h +++ b/content/browser/renderer_host/browser_render_process_host.h @@ -47,7 +47,7 @@ class BrowserRenderProcessHost : public RenderProcessHost, ~BrowserRenderProcessHost(); // RenderProcessHost implementation (public portion). - virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process); + virtual bool Init(bool is_accessibility_enabled); virtual int GetNextRoutingID(); virtual void CancelResourceRequests(int render_widget_id); virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params); @@ -130,9 +130,9 @@ class BrowserRenderProcessHost : public RenderProcessHost, // True if this prcoess should have accessibility enabled; bool accessibility_enabled_; - // True iff this process is being used as an extension process. Not valid - // when running in single-process mode. - bool extension_process_; + // True after Init() has been called. We can't just check channel_ because we + // also reset that in the case of process termination. + bool is_initialized_; // Used to launch and terminate the process without blocking the UI thread. scoped_ptr<ChildProcessLauncher> child_process_launcher_; diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc index 104395f..dec107a 100644 --- a/content/browser/renderer_host/mock_render_process_host.cc +++ b/content/browser/renderer_host/mock_render_process_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -23,8 +23,7 @@ MockRenderProcessHost::~MockRenderProcessHost() { factory_->Remove(this); } -bool MockRenderProcessHost::Init( - bool is_accessibility_enabled, bool is_extensions_process) { +bool MockRenderProcessHost::Init(bool is_accessibility_enabled) { return true; } diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h index 0e7656c..a6804a1 100644 --- a/content/browser/renderer_host/mock_render_process_host.h +++ b/content/browser/renderer_host/mock_render_process_host.h @@ -36,7 +36,7 @@ class MockRenderProcessHost : public RenderProcessHost { int bad_msg_count() const { return bad_msg_count_; } // RenderProcessHost implementation (public portion). - virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process); + virtual bool Init(bool is_accessibility_enabled); virtual int GetNextRoutingID(); virtual void CancelResourceRequests(int render_widget_id); virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params); diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc index cf380ab..f435e7c 100644 --- a/content/browser/renderer_host/render_process_host.cc +++ b/content/browser/renderer_host/render_process_host.cc @@ -94,6 +94,7 @@ RenderProcessHost::RenderProcessHost(Profile* profile) : max_page_id_(-1), fast_shutdown_started_(false), deleting_soon_(false), + is_extension_process_(false), id_(ChildProcessInfo::GenerateChildProcessUniqueId()), profile_(profile), sudden_termination_allowed_(true), diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h index b384026..4a76d1f 100644 --- a/content/browser/renderer_host/render_process_host.h +++ b/content/browser/renderer_host/render_process_host.h @@ -88,6 +88,9 @@ class RenderProcessHost : public IPC::Channel::Sender, sudden_termination_allowed_ = enabled; } + bool is_extension_process() const { return is_extension_process_; } + void mark_is_extension_process() { is_extension_process_ = true; } + // 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. @@ -157,8 +160,7 @@ class RenderProcessHost : public IPC::Channel::Sender, // 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, bool is_extensions_process) = 0; + virtual bool Init(bool is_accessibility_enabled) = 0; // Gets the next available routing id. virtual int GetNextRoutingID() = 0; @@ -276,6 +278,10 @@ class RenderProcessHost : public IPC::Channel::Sender, // True if we've posted a DeleteTask and will be deleted soon. bool deleting_soon_; + // True iff this process is being used as an extension process. Not valid + // when running in single-process mode. + bool is_extension_process_; + private: // The globally-unique identifier for this RPH. int id_; diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 47e5457..c74ac5e 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -102,7 +102,6 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, are_javascript_messages_suppressed_(false), sudden_termination_allowed_(false), session_storage_namespace_(session_storage), - is_extension_process_(false), save_accessibility_tree_for_testing_(false), render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { if (!session_storage_namespace_) { @@ -114,6 +113,11 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, DCHECK(delegate_); content::GetContentClient()->browser()->RenderViewHostCreated(this); + + NotificationService::current()->Notify( + NotificationType::RENDER_VIEW_HOST_CREATED, + Source<RenderViewHost>(this), + NotificationService::NoDetails()); } RenderViewHost::~RenderViewHost() { @@ -139,7 +143,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { // initialized it) or may not (we have our own process or the old process // crashed) have been initialized. Calling Init multiple times will be // ignored, so this is safe. - if (!process()->Init(renderer_accessible(), is_extension_process_)) + if (!process()->Init(renderer_accessible())) return false; DCHECK(process()->HasConnection()); DCHECK(process()->profile()); @@ -152,10 +156,6 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) { if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) { ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings( process()->id()); - - // Extensions may have permission to access chrome:// URLs. - ChildProcessSecurityPolicy::GetInstance()->GrantScheme( - process()->id(), chrome::kChromeUIScheme); } renderer_initialized_ = true; diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index bfd7bf85..b29f2ed 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -314,12 +314,6 @@ class RenderViewHost : public RenderWidgetHost { // RenderView. See BindingsPolicy for details. int enabled_bindings() const { return enabled_bindings_; } - // See variable comment. - bool is_extension_process() const { return is_extension_process_; } - void set_is_extension_process(bool is_extension_process) { - is_extension_process_ = is_extension_process; - } - // Sets a property with the given name and value on the Web UI binding object. // Must call AllowWebUIBindings() on this renderer first. void SetWebUIProperty(const std::string& name, const std::string& value); @@ -599,10 +593,6 @@ class RenderViewHost : public RenderWidgetHost { // The session storage namespace to be used by the associated render view. scoped_refptr<SessionStorageNamespace> session_storage_namespace_; - // Whether this render view will get extension api bindings. This controls - // what process type we use. - bool is_extension_process_; - // Whether the accessibility tree should be saved, for unit testing. bool save_accessibility_tree_for_testing_; diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index d08f6ab..7effc09 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -480,11 +480,6 @@ bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, if (pending_web_ui_.get()) render_view_host->AllowBindings(pending_web_ui_->bindings()); - // Give the embedder a chance to initialize the render view. - Profile* profile = delegate_->GetControllerForRenderManager().profile(); - content::GetContentClient()->browser()->PreCreateRenderView( - render_view_host, profile, entry.url()); - return delegate_->CreateRenderViewForRenderManager(render_view_host); } diff --git a/content/common/notification_type.h b/content/common/notification_type.h index 9b9ab0d..85a829b 100644 --- a/content/common/notification_type.h +++ b/content/common/notification_type.h @@ -454,6 +454,10 @@ class NotificationType { // Used only in testing. RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, + // Sent from RenderViewHost constructor. The source is the RenderViewHost, + // the details unused. + RENDER_VIEW_HOST_CREATED, + // Sent from ~RenderViewHost. The source is the RenderViewHost, the details // unused. RENDER_VIEW_HOST_DELETED, @@ -860,18 +864,6 @@ class NotificationType { // Extension, and the source is a Profile. EXTENSION_USER_SCRIPTS_UPDATED, - // Sent after a new ExtensionFunctionDispatcher is created. The details are - // an ExtensionFunctionDispatcher* and the source is a Profile*. This is - // similar in timing to EXTENSION_HOST_CREATED, but also fires when an - // extension view which is hosted in TabContents* is created. - EXTENSION_FUNCTION_DISPATCHER_CREATED, - - // Sent before an ExtensionHost is destroyed. The details are - // an ExtensionFunctionDispatcher* and the source is a Profile*. This is - // similar in timing to EXTENSION_HOST_DESTROYED, but also fires when an - // extension view which is hosted in TabContents* is destroyed. - EXTENSION_FUNCTION_DISPATCHER_DESTROYED, - // Sent after a new ExtensionHost is created. The details are // an ExtensionHost* and the source is an ExtensionProcessManager*. EXTENSION_HOST_CREATED, |