diff options
author | Daniel Xie <dxie@google.com> | 2015-03-14 15:22:26 -0700 |
---|---|---|
committer | Daniel Xie <dxie@google.com> | 2015-03-14 22:23:29 +0000 |
commit | 9851a4a9c8541188debab6275a4f55e8b8e7cd66 (patch) | |
tree | 79684789c422f7827968295840dec5aee27d07f7 /extensions/browser/extension_host.cc | |
parent | 89c8b88b60db6b91a8cdbb42fd36aca7e098e101 (diff) | |
download | chromium_src-9851a4a9c8541188debab6275a4f55e8b8e7cd66.zip chromium_src-9851a4a9c8541188debab6275a4f55e8b8e7cd66.tar.gz chromium_src-9851a4a9c8541188debab6275a4f55e8b8e7cd66.tar.bz2 |
Merge remote-tracking branch 'refs/remotes/origin/master'
Revert "Make LoadMonitoringExtensionHostQueue remove itself as an ExtensionHost observer at the correct time." BUG=467353 This reverts commit 4eefc7b64335c6008a1e5218c230dadd733875a7.
Cr-Commit-Position: refs/heads/master@{#320671}
Diffstat (limited to 'extensions/browser/extension_host.cc')
-rw-r--r-- | extensions/browser/extension_host.cc | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/extensions/browser/extension_host.cc b/extensions/browser/extension_host.cc index df92489..bbf51ef 100644 --- a/extensions/browser/extension_host.cc +++ b/extensions/browser/extension_host.cc @@ -58,7 +58,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, extension_id_(extension->id()), browser_context_(site_instance->GetBrowserContext()), render_view_host_(nullptr), - has_loaded_once_(false), + did_stop_loading_(false), document_element_available_(false), initial_url_(url), extension_function_dispatcher_(browser_context_, this), @@ -92,7 +92,6 @@ ExtensionHost::~ExtensionHost() { UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime2", load_start_->Elapsed()); } - content::NotificationService::current()->Notify( extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, content::Source<BrowserContext>(browser_context_), @@ -102,16 +101,11 @@ ExtensionHost::~ExtensionHost() { FOR_EACH_OBSERVER(DeferredStartRenderHostObserver, deferred_start_render_host_observer_list_, OnDeferredStartRenderHostDestroyed(this)); - - // Remove ourselves from the queue as late as possible (before effectively - // destroying self, but after everything else) so that queues that are - // monitoring lifetime get a chance to see stop-loading events. delegate_->GetExtensionHostQueue()->Remove(this); - - // Deliberately stop observing |host_contents_| because its destruction - // events (like DidStopLoading, it turns out) can call back into - // ExtensionHost re-entrantly, when anything declared after |host_contents_| - // has already been destroyed. + // Immediately stop observing |host_contents_| because its destruction events + // (like DidStopLoading, it turns out) can call back into ExtensionHost + // re-entrantly, when anything declared after |host_contents_| has already + // been destroyed. content::WebContentsObserver::Observe(nullptr); } @@ -225,7 +219,7 @@ void ExtensionHost::LoadInitialURL() { } bool ExtensionHost::IsBackgroundPage() const { - DCHECK_EQ(extension_host_type_, VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); + DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); return true; } @@ -274,23 +268,35 @@ void ExtensionHost::DidStartLoading(content::RenderViewHost* render_view_host) { } void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) { - // Only record UMA for the first load. Subsequent loads will likely behave - // quite different, and it's first load we're most interested in. - if (!has_loaded_once_) - RecordStopLoadingUMA(); - has_loaded_once_ = true; + bool notify = !did_stop_loading_; + did_stop_loading_ = true; OnDidStopLoading(); - content::NotificationService::current()->Notify( - extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, - content::Source<BrowserContext>(browser_context_), - content::Details<ExtensionHost>(this)); - FOR_EACH_OBSERVER(DeferredStartRenderHostObserver, - deferred_start_render_host_observer_list_, - OnDeferredStartRenderHostDidStopLoading(this)); + if (notify) { + CHECK(load_start_.get()); + if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { + UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.EventPageLoadTime2", + load_start_->Elapsed()); + } else { + UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.BackgroundPageLoadTime2", + load_start_->Elapsed()); + } + } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { + UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", + load_start_->Elapsed()); + } + content::NotificationService::current()->Notify( + extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, + content::Source<BrowserContext>(browser_context_), + content::Details<ExtensionHost>(this)); + FOR_EACH_OBSERVER(DeferredStartRenderHostObserver, + deferred_start_render_host_observer_list_, + OnDeferredStartRenderHostDidStopLoading(this)); + } } void ExtensionHost::OnDidStopLoading() { - DCHECK_EQ(extension_host_type_, VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); + DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); // Nothing to do for background pages. } @@ -455,20 +461,4 @@ bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; } -void ExtensionHost::RecordStopLoadingUMA() { - CHECK(load_start_.get()); - if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { - if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { - UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.EventPageLoadTime2", - load_start_->Elapsed()); - } else { - UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.BackgroundPageLoadTime2", - load_start_->Elapsed()); - } - } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { - UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", - load_start_->Elapsed()); - } -} - } // namespace extensions |