OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_process_manager.h" | 5 #include "chrome/browser/extensions/extension_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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 ExtensionHost* host = | 297 ExtensionHost* host = |
298 #if defined(OS_MACOSX) | 298 #if defined(OS_MACOSX) |
299 new extensions::ExtensionHostMac( | 299 new extensions::ExtensionHostMac( |
300 extension, GetSiteInstanceForURL(url), url, | 300 extension, GetSiteInstanceForURL(url), url, |
301 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 301 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
302 #else | 302 #else |
303 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, | 303 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
304 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 304 extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
305 #endif | 305 #endif |
306 | 306 |
307 host->CreateRenderViewSoon(); | 307 if (defer_background_host_creation_) |
Matt Perry
2013/08/31 00:22:23
Since you're doing this for all background hosts,
Greg Spencer (Chromium)
2013/09/03 19:09:31
Good point, that does simplify things. Done.
| |
308 host->CreateRenderViewDeferred(); | |
309 else | |
310 host->CreateRenderViewSoon(); | |
308 OnExtensionHostCreated(host, true); | 311 OnExtensionHostCreated(host, true); |
309 } | 312 } |
310 | 313 |
311 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( | 314 ExtensionHost* ExtensionProcessManager::GetBackgroundHostForExtension( |
312 const std::string& extension_id) { | 315 const std::string& extension_id) { |
313 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); | 316 for (ExtensionHostSet::iterator iter = background_hosts_.begin(); |
314 iter != background_hosts_.end(); ++iter) { | 317 iter != background_hosts_.end(); ++iter) { |
315 ExtensionHost* host = *iter; | 318 ExtensionHost* host = *iter; |
316 if (host->extension_id() == extension_id) | 319 if (host->extension_id() == extension_id) |
317 return host; | 320 return host; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 new ExtensionMsg_CancelSuspend(extension->id())); | 540 new ExtensionMsg_CancelSuspend(extension->id())); |
538 // This increment / decrement is to simulate an instantaneous event. This | 541 // This increment / decrement is to simulate an instantaneous event. This |
539 // has the effect of invalidating close_sequence_id, preventing any in | 542 // has the effect of invalidating close_sequence_id, preventing any in |
540 // progress closes from completing and starting a new close process if | 543 // progress closes from completing and starting a new close process if |
541 // necessary. | 544 // necessary. |
542 IncrementLazyKeepaliveCount(extension); | 545 IncrementLazyKeepaliveCount(extension); |
543 DecrementLazyKeepaliveCount(extension); | 546 DecrementLazyKeepaliveCount(extension); |
544 } | 547 } |
545 } | 548 } |
546 | 549 |
550 void ExtensionProcessManager::DeferBackgroundHostCreation(bool defer) { | |
551 defer_background_host_creation_ = defer; | |
552 } | |
553 | |
554 void ExtensionProcessManager::CreateDeferredBackgroundHosts() { | |
555 ExtensionHost::CreateDeferredRenderViews(); | |
556 } | |
557 | |
547 void ExtensionProcessManager::Observe( | 558 void ExtensionProcessManager::Observe( |
548 int type, | 559 int type, |
549 const content::NotificationSource& source, | 560 const content::NotificationSource& source, |
550 const content::NotificationDetails& details) { | 561 const content::NotificationDetails& details) { |
551 switch (type) { | 562 switch (type) { |
552 case chrome::NOTIFICATION_BROWSER_WINDOW_READY: { | 563 case chrome::NOTIFICATION_BROWSER_WINDOW_READY: { |
553 // If a window for this profile, or this profile's incognito profile, | 564 // If a window for this profile, or this profile's incognito profile, |
554 // has been opened, make sure this profile's background hosts have | 565 // has been opened, make sure this profile's background hosts have |
555 // been loaded. | 566 // been loaded. |
556 Browser* browser = content::Source<Browser>(source).ptr(); | 567 Browser* browser = content::Source<Browser>(source).ptr(); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 if (service && service->is_ready()) | 904 if (service && service->is_ready()) |
894 CreateBackgroundHostsForProfileStartup(); | 905 CreateBackgroundHostsForProfileStartup(); |
895 } | 906 } |
896 break; | 907 break; |
897 } | 908 } |
898 default: | 909 default: |
899 ExtensionProcessManager::Observe(type, source, details); | 910 ExtensionProcessManager::Observe(type, source, details); |
900 break; | 911 break; |
901 } | 912 } |
902 } | 913 } |
OLD | NEW |