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

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

Issue 147923005: Split ExtensionSystem interface from ExtensionSystemImpl implementation, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re^3base Created 6 years, 10 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
« no previous file with comments | « extensions/browser/lazy_background_task_queue.cc ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/api/runtime/runtime_api.h" 17 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
18 #include "chrome/browser/extensions/extension_host.h" 18 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/extensions/extension_util.h" 20 #include "chrome/browser/extensions/extension_util.h"
22 #include "chrome/common/extensions/extension_messages.h" 21 #include "chrome/common/extensions/extension_messages.h"
23 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/devtools_agent_host.h" 24 #include "content/public/browser/devtools_agent_host.h"
26 #include "content/public/browser/devtools_manager.h" 25 #include "content/public/browser/devtools_manager.h"
27 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/site_instance.h" 30 #include "content/public/browser/site_instance.h"
32 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_contents_delegate.h" 32 #include "content/public/browser/web_contents_delegate.h"
34 #include "content/public/browser/web_contents_observer.h" 33 #include "content/public/browser/web_contents_observer.h"
35 #include "content/public/browser/web_contents_user_data.h" 34 #include "content/public/browser/web_contents_user_data.h"
36 #include "content/public/common/renderer_preferences.h" 35 #include "content/public/common/renderer_preferences.h"
37 #include "extensions/browser/extension_registry.h" 36 #include "extensions/browser/extension_registry.h"
37 #include "extensions/browser/extension_system.h"
38 #include "extensions/browser/extensions_browser_client.h" 38 #include "extensions/browser/extensions_browser_client.h"
39 #include "extensions/browser/view_type_utils.h" 39 #include "extensions/browser/view_type_utils.h"
40 #include "extensions/common/extension.h" 40 #include "extensions/common/extension.h"
41 #include "extensions/common/manifest_handlers/background_info.h" 41 #include "extensions/common/manifest_handlers/background_info.h"
42 #include "extensions/common/manifest_handlers/incognito_info.h" 42 #include "extensions/common/manifest_handlers/incognito_info.h"
43 #include "extensions/common/switches.h" 43 #include "extensions/common/switches.h"
44 44
45 using content::BrowserContext; 45 using content::BrowserContext;
46 using content::RenderViewHost; 46 using content::RenderViewHost;
47 using content::SiteInstance; 47 using content::SiteInstance;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 class RenderViewHostDestructionObserver 121 class RenderViewHostDestructionObserver
122 : public content::WebContentsObserver, 122 : public content::WebContentsObserver,
123 public content::WebContentsUserData<RenderViewHostDestructionObserver> { 123 public content::WebContentsUserData<RenderViewHostDestructionObserver> {
124 public: 124 public:
125 virtual ~RenderViewHostDestructionObserver() {} 125 virtual ~RenderViewHostDestructionObserver() {}
126 126
127 private: 127 private:
128 explicit RenderViewHostDestructionObserver(WebContents* web_contents) 128 explicit RenderViewHostDestructionObserver(WebContents* web_contents)
129 : WebContentsObserver(web_contents) { 129 : WebContentsObserver(web_contents) {
130 BrowserContext* context = web_contents->GetBrowserContext(); 130 BrowserContext* context = web_contents->GetBrowserContext();
131 process_manager_ = 131 process_manager_ = ExtensionSystem::Get(context)->process_manager();
132 ExtensionSystem::GetForBrowserContext(context)->process_manager();
133 } 132 }
134 133
135 friend class content::WebContentsUserData<RenderViewHostDestructionObserver>; 134 friend class content::WebContentsUserData<RenderViewHostDestructionObserver>;
136 135
137 // content::WebContentsObserver overrides. 136 // content::WebContentsObserver overrides.
138 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE { 137 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE {
139 process_manager_->UnregisterRenderViewHost(render_view_host); 138 process_manager_->UnregisterRenderViewHost(render_view_host);
140 } 139 }
141 140
142 ProcessManager* process_manager_; 141 ProcessManager* process_manager_;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // This increment / decrement is to simulate an instantaneous event. This 562 // This increment / decrement is to simulate an instantaneous event. This
564 // has the effect of invalidating close_sequence_id, preventing any in 563 // has the effect of invalidating close_sequence_id, preventing any in
565 // progress closes from completing and starting a new close process if 564 // progress closes from completing and starting a new close process if
566 // necessary. 565 // necessary.
567 IncrementLazyKeepaliveCount(extension); 566 IncrementLazyKeepaliveCount(extension);
568 DecrementLazyKeepaliveCount(extension); 567 DecrementLazyKeepaliveCount(extension);
569 } 568 }
570 } 569 }
571 570
572 void ProcessManager::OnBrowserWindowReady() { 571 void ProcessManager::OnBrowserWindowReady() {
573 ExtensionService* service = ExtensionSystem::GetForBrowserContext( 572 ExtensionService* service = ExtensionSystem::Get(
574 GetBrowserContext())->extension_service(); 573 GetBrowserContext())->extension_service();
575 // On Chrome OS, a login screen is implemented as a browser. 574 // On Chrome OS, a login screen is implemented as a browser.
576 // This browser has no extension service. In this case, 575 // This browser has no extension service. In this case,
577 // service will be NULL. 576 // service will be NULL.
578 if (!service || !service->is_ready()) 577 if (!service || !service->is_ready())
579 return; 578 return;
580 579
581 CreateBackgroundHostsForProfileStartup(); 580 CreateBackgroundHostsForProfileStartup();
582 } 581 }
583 582
(...skipping 22 matching lines...) Expand all
606 // (or an incognito profile from this profile) is ready. 605 // (or an incognito profile from this profile) is ready.
607 if (DeferLoadingBackgroundHosts()) 606 if (DeferLoadingBackgroundHosts())
608 break; 607 break;
609 608
610 CreateBackgroundHostsForProfileStartup(); 609 CreateBackgroundHostsForProfileStartup();
611 break; 610 break;
612 } 611 }
613 612
614 case chrome::NOTIFICATION_EXTENSION_LOADED: { 613 case chrome::NOTIFICATION_EXTENSION_LOADED: {
615 BrowserContext* context = content::Source<BrowserContext>(source).ptr(); 614 BrowserContext* context = content::Source<BrowserContext>(source).ptr();
616 ExtensionSystem* system = ExtensionSystem::GetForBrowserContext(context); 615 ExtensionSystem* system = ExtensionSystem::Get(context);
617 if (system->ready().is_signaled()) { 616 if (system->ready().is_signaled()) {
618 // The extension system is ready, so create the background host. 617 // The extension system is ready, so create the background host.
619 const Extension* extension = 618 const Extension* extension =
620 content::Details<const Extension>(details).ptr(); 619 content::Details<const Extension>(details).ptr();
621 CreateBackgroundHostForExtensionLoad(this, extension); 620 CreateBackgroundHostForExtensionLoad(this, extension);
622 } 621 }
623 break; 622 break;
624 } 623 }
625 624
626 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 625 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 845 }
847 846
848 // 847 //
849 // IncognitoProcessManager 848 // IncognitoProcessManager
850 // 849 //
851 850
852 IncognitoProcessManager::IncognitoProcessManager( 851 IncognitoProcessManager::IncognitoProcessManager(
853 BrowserContext* incognito_context, 852 BrowserContext* incognito_context,
854 BrowserContext* original_context) 853 BrowserContext* original_context)
855 : ProcessManager(incognito_context, original_context), 854 : ProcessManager(incognito_context, original_context),
856 original_manager_(ExtensionSystem::GetForBrowserContext( 855 original_manager_(
857 original_context)->process_manager()) { 856 ExtensionSystem::Get(original_context)->process_manager()) {
858 DCHECK(incognito_context->IsOffTheRecord()); 857 DCHECK(incognito_context->IsOffTheRecord());
859 858
860 // The original profile will have its own ProcessManager to 859 // The original profile will have its own ProcessManager to
861 // load the background pages of the spanning extensions. This process 860 // load the background pages of the spanning extensions. This process
862 // manager need only worry about the split mode extensions, which is handled 861 // manager need only worry about the split mode extensions, which is handled
863 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler. 862 // in the NOTIFICATION_BROWSER_WINDOW_READY notification handler.
864 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY, 863 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
865 content::Source<BrowserContext>(original_context)); 864 content::Source<BrowserContext>(original_context));
866 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED, 865 registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_CREATED,
867 content::Source<BrowserContext>(original_context)); 866 content::Source<BrowserContext>(original_context));
(...skipping 17 matching lines...) Expand all
885 const Extension* extension = 884 const Extension* extension =
886 registry->enabled_extensions().GetExtensionOrAppByURL(url); 885 registry->enabled_extensions().GetExtensionOrAppByURL(url);
887 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 886 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
888 return original_manager_->GetSiteInstanceForURL(url); 887 return original_manager_->GetSiteInstanceForURL(url);
889 } 888 }
890 } 889 }
891 return ProcessManager::GetSiteInstanceForURL(url); 890 return ProcessManager::GetSiteInstanceForURL(url);
892 } 891 }
893 892
894 } // namespace extensions 893 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/lazy_background_task_queue.cc ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698