OLD | NEW |
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 void ProcessManager::DecrementLazyKeepaliveCount(const Extension* extension) { | 430 void ProcessManager::DecrementLazyKeepaliveCount(const Extension* extension) { |
431 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) | 431 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) |
432 return; | 432 return; |
433 DecrementLazyKeepaliveCount(extension->id()); | 433 DecrementLazyKeepaliveCount(extension->id()); |
434 } | 434 } |
435 | 435 |
436 void ProcessManager::DecrementLazyKeepaliveCount( | 436 void ProcessManager::DecrementLazyKeepaliveCount( |
437 const std::string& extension_id) { | 437 const std::string& extension_id) { |
438 int& count = background_page_data_[extension_id].lazy_keepalive_count; | 438 int& count = background_page_data_[extension_id].lazy_keepalive_count; |
439 DCHECK_GT(count, 0); | 439 DCHECK(count > 0 || |
| 440 !ExtensionRegistry::Get(GetBrowserContext()) |
| 441 ->enabled_extensions() |
| 442 .Contains(extension_id)); |
440 | 443 |
441 // If we reach a zero keepalive count when the lazy background page is about | 444 // If we reach a zero keepalive count when the lazy background page is about |
442 // to be closed, incrementing close_sequence_id will cancel the close | 445 // to be closed, incrementing close_sequence_id will cancel the close |
443 // sequence and cause the background page to linger. So check is_closing | 446 // sequence and cause the background page to linger. So check is_closing |
444 // before initiating another close sequence. | 447 // before initiating another close sequence. |
445 if (--count == 0 && !background_page_data_[extension_id].is_closing) { | 448 if (--count == 0 && !background_page_data_[extension_id].is_closing) { |
446 base::MessageLoop::current()->PostDelayedTask( | 449 base::MessageLoop::current()->PostDelayedTask( |
447 FROM_HERE, | 450 FROM_HERE, |
448 base::Bind(&ProcessManager::OnLazyBackgroundPageIdle, | 451 base::Bind(&ProcessManager::OnLazyBackgroundPageIdle, |
449 weak_ptr_factory_.GetWeakPtr(), extension_id, | 452 weak_ptr_factory_.GetWeakPtr(), extension_id, |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 const Extension* extension = | 931 const Extension* extension = |
929 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 932 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
930 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 933 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
931 return original_manager_->GetSiteInstanceForURL(url); | 934 return original_manager_->GetSiteInstanceForURL(url); |
932 } | 935 } |
933 } | 936 } |
934 return ProcessManager::GetSiteInstanceForURL(url); | 937 return ProcessManager::GetSiteInstanceForURL(url); |
935 } | 938 } |
936 | 939 |
937 } // namespace extensions | 940 } // namespace extensions |
OLD | NEW |