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