Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: extensions/browser/process_manager.cc

Issue 415933003: Remove chrome::NOTIFICATION_PROFILE_DESTROYED usage from src/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/process_manager.h" 5 #include "extensions/browser/process_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 256 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
257 content::Source<BrowserContext>(original_context)); 257 content::Source<BrowserContext>(original_context));
258 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 258 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
259 content::Source<BrowserContext>(context)); 259 content::Source<BrowserContext>(context));
260 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 260 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
261 content::Source<BrowserContext>(context)); 261 content::Source<BrowserContext>(context));
262 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 262 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
263 content::NotificationService::AllSources()); 263 content::NotificationService::AllSources());
264 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, 264 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
265 content::NotificationService::AllSources()); 265 content::NotificationService::AllSources());
266 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
267 content::Source<BrowserContext>(context));
268 if (context->IsOffTheRecord()) {
269 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
270 content::Source<BrowserContext>(original_context));
271 }
272 266
273 // Note: event_page_idle_time_ must be sufficiently larger (e.g. 2x) than 267 // Note: event_page_idle_time_ must be sufficiently larger (e.g. 2x) than
274 // kKeepaliveThrottleIntervalInSeconds in ppapi/proxy/plugin_globals. 268 // kKeepaliveThrottleIntervalInSeconds in ppapi/proxy/plugin_globals.
275 event_page_idle_time_ = base::TimeDelta::FromSeconds(10); 269 event_page_idle_time_ = base::TimeDelta::FromSeconds(10);
276 unsigned idle_time_msec = 0; 270 unsigned idle_time_msec = 0;
277 if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 271 if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
278 extensions::switches::kEventPageIdleTime), &idle_time_msec)) { 272 extensions::switches::kEventPageIdleTime), &idle_time_msec)) {
279 CHECK_GT(idle_time_msec, 0u); // OnKeepaliveImpulseCheck requires non zero. 273 CHECK_GT(idle_time_msec, 0u); // OnKeepaliveImpulseCheck requires non zero.
280 event_page_idle_time_ = base::TimeDelta::FromMilliseconds(idle_time_msec); 274 event_page_idle_time_ = base::TimeDelta::FromMilliseconds(idle_time_msec);
281 } 275 }
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 new ExtensionMsg_CancelSuspend(extension->id())); 620 new ExtensionMsg_CancelSuspend(extension->id()));
627 // This increment / decrement is to simulate an instantaneous event. This 621 // This increment / decrement is to simulate an instantaneous event. This
628 // has the effect of invalidating close_sequence_id, preventing any in 622 // has the effect of invalidating close_sequence_id, preventing any in
629 // progress closes from completing and starting a new close process if 623 // progress closes from completing and starting a new close process if
630 // necessary. 624 // necessary.
631 IncrementLazyKeepaliveCount(extension); 625 IncrementLazyKeepaliveCount(extension);
632 DecrementLazyKeepaliveCount(extension); 626 DecrementLazyKeepaliveCount(extension);
633 } 627 }
634 } 628 }
635 629
630 void ProcessManager::CloseBackgroundHosts() {
James Cook 2014/07/24 18:27:54 Moved unchanged from below to match declaration or
631 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
632 iter != background_hosts_.end();) {
633 ExtensionHostSet::iterator current = iter++;
634 delete *current;
635 }
636 }
637
636 content::BrowserContext* ProcessManager::GetBrowserContext() const { 638 content::BrowserContext* ProcessManager::GetBrowserContext() const {
637 return site_instance_->GetBrowserContext(); 639 return site_instance_->GetBrowserContext();
638 } 640 }
639 641
640 void ProcessManager::SetKeepaliveImpulseCallbackForTesting( 642 void ProcessManager::SetKeepaliveImpulseCallbackForTesting(
641 const ImpulseCallbackForTesting& callback) { 643 const ImpulseCallbackForTesting& callback) {
642 keepalive_impulse_callback_for_testing_ = callback; 644 keepalive_impulse_callback_for_testing_ = callback;
643 } 645 }
644 646
645 void ProcessManager::SetKeepaliveImpulseDecrementCallbackForTesting( 647 void ProcessManager::SetKeepaliveImpulseDecrementCallbackForTesting(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 740
739 // RegisterRenderViewHost is called too early (before the process is 741 // RegisterRenderViewHost is called too early (before the process is
740 // available), so we need to wait until now to notify. 742 // available), so we need to wait until now to notify.
741 content::NotificationService::current()->Notify( 743 content::NotificationService::current()->Notify(
742 chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED, 744 chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED,
743 content::Source<BrowserContext>(GetBrowserContext()), 745 content::Source<BrowserContext>(GetBrowserContext()),
744 content::Details<RenderViewHost>(contents->GetRenderViewHost())); 746 content::Details<RenderViewHost>(contents->GetRenderViewHost()));
745 break; 747 break;
746 } 748 }
747 749
748 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
749 // Close background hosts when the last browser is closed so that they
750 // have time to shutdown various objects on different threads. Our
751 // destructor is called too late in the shutdown sequence.
752 CloseBackgroundHosts();
753 break;
754 }
755
756 default: 750 default:
757 NOTREACHED(); 751 NOTREACHED();
758 } 752 }
759 } 753 }
760 754
761 void ProcessManager::OnDevToolsStateChanged( 755 void ProcessManager::OnDevToolsStateChanged(
762 content::DevToolsAgentHost* agent_host, 756 content::DevToolsAgentHost* agent_host,
763 bool attached) { 757 bool attached) {
764 RenderViewHost* rvh = agent_host->GetRenderViewHost(); 758 RenderViewHost* rvh = agent_host->GetRenderViewHost();
765 // Ignore unrelated notifications. 759 // Ignore unrelated notifications.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 841 }
848 842
849 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { 843 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) {
850 CHECK(host->extension_host_type() == 844 CHECK(host->extension_host_type() ==
851 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 845 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
852 delete host; 846 delete host;
853 // |host| should deregister itself from our structures. 847 // |host| should deregister itself from our structures.
854 CHECK(background_hosts_.find(host) == background_hosts_.end()); 848 CHECK(background_hosts_.find(host) == background_hosts_.end());
855 } 849 }
856 850
857 void ProcessManager::CloseBackgroundHosts() {
858 for (ExtensionHostSet::iterator iter = background_hosts_.begin();
859 iter != background_hosts_.end(); ) {
860 ExtensionHostSet::iterator current = iter++;
861 delete *current;
862 }
863 }
864
865 void ProcessManager::UnregisterExtension(const std::string& extension_id) { 851 void ProcessManager::UnregisterExtension(const std::string& extension_id) {
866 // The lazy_keepalive_count may be greater than zero at this point because 852 // The lazy_keepalive_count may be greater than zero at this point because
867 // RenderViewHosts are still alive. During extension reloading, they will 853 // RenderViewHosts are still alive. During extension reloading, they will
868 // decrement the lazy_keepalive_count to negative for the new extension 854 // decrement the lazy_keepalive_count to negative for the new extension
869 // instance when they are destroyed. Since we are erasing the background page 855 // instance when they are destroyed. Since we are erasing the background page
870 // data for the unloaded extension, unregister the RenderViewHosts too. 856 // data for the unloaded extension, unregister the RenderViewHosts too.
871 BrowserContext* context = GetBrowserContext(); 857 BrowserContext* context = GetBrowserContext();
872 for (ExtensionRenderViews::iterator it = all_extension_views_.begin(); 858 for (ExtensionRenderViews::iterator it = all_extension_views_.begin();
873 it != all_extension_views_.end(); ) { 859 it != all_extension_views_.end(); ) {
874 if (GetExtensionID(it->first) == extension_id) { 860 if (GetExtensionID(it->first) == extension_id) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) { 918 SiteInstance* IncognitoProcessManager::GetSiteInstanceForURL(const GURL& url) {
933 const Extension* extension = 919 const Extension* extension =
934 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url); 920 extension_registry_->enabled_extensions().GetExtensionOrAppByURL(url);
935 if (extension && !IncognitoInfo::IsSplitMode(extension)) 921 if (extension && !IncognitoInfo::IsSplitMode(extension))
936 return original_manager_->GetSiteInstanceForURL(url); 922 return original_manager_->GetSiteInstanceForURL(url);
937 923
938 return ProcessManager::GetSiteInstanceForURL(url); 924 return ProcessManager::GetSiteInstanceForURL(url);
939 } 925 }
940 926
941 } // namespace extensions 927 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698