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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 BackgroundPageData& bd = background_page_data_[extension->id()]; | 437 BackgroundPageData& bd = background_page_data_[extension->id()]; |
438 | 438 |
439 if (!bd.keepalive_impulse) { | 439 if (!bd.keepalive_impulse) { |
440 bd.keepalive_impulse = true; | 440 bd.keepalive_impulse = true; |
441 if (!bd.previous_keepalive_impulse) { | 441 if (!bd.previous_keepalive_impulse) { |
442 IncrementLazyKeepaliveCount(extension); | 442 IncrementLazyKeepaliveCount(extension); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 if (!keepalive_impulse_callback_for_testing_.is_null()) | 446 if (!keepalive_impulse_callback_for_testing_.is_null()) { |
447 keepalive_impulse_callback_for_testing_.Run(extension->id()); | 447 ImpulseCallbackForTesting callback_may_clear_callbacks_reentrantly = |
| 448 keepalive_impulse_callback_for_testing_; |
| 449 callback_may_clear_callbacks_reentrantly.Run(extension->id()); |
| 450 } |
448 } | 451 } |
449 | 452 |
450 // DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse | 453 // DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse |
451 // have been made for at least event_page_idle_time_. In the best case an | 454 // have been made for at least event_page_idle_time_. In the best case an |
452 // impulse was made just before being cleared, and the decrement will occur | 455 // impulse was made just before being cleared, and the decrement will occur |
453 // event_page_idle_time_ later, causing a 2 * event_page_idle_time_ total time | 456 // event_page_idle_time_ later, causing a 2 * event_page_idle_time_ total time |
454 // for extension to be shut down based on impulses. Worst case is an impulse | 457 // for extension to be shut down based on impulses. Worst case is an impulse |
455 // just after a clear, adding one check cycle and resulting in 3x total time. | 458 // just after a clear, adding one check cycle and resulting in 3x total time. |
456 void ProcessManager::OnKeepaliveImpulseCheck() { | 459 void ProcessManager::OnKeepaliveImpulseCheck() { |
457 for (BackgroundPageDataMap::iterator i = background_page_data_.begin(); | 460 for (BackgroundPageDataMap::iterator i = background_page_data_.begin(); |
458 i != background_page_data_.end(); | 461 i != background_page_data_.end(); |
459 ++i) { | 462 ++i) { |
460 if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) { | 463 if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) { |
461 DecrementLazyKeepaliveCount(i->first); | 464 DecrementLazyKeepaliveCount(i->first); |
462 if (!keepalive_impulse_decrement_callback_for_testing_.is_null()) | 465 if (!keepalive_impulse_decrement_callback_for_testing_.is_null()) { |
463 keepalive_impulse_decrement_callback_for_testing_.Run(i->first); | 466 ImpulseCallbackForTesting callback_may_clear_callbacks_reentrantly = |
| 467 keepalive_impulse_decrement_callback_for_testing_; |
| 468 callback_may_clear_callbacks_reentrantly.Run(i->first); |
| 469 } |
464 } | 470 } |
465 | 471 |
466 i->second.previous_keepalive_impulse = i->second.keepalive_impulse; | 472 i->second.previous_keepalive_impulse = i->second.keepalive_impulse; |
467 i->second.keepalive_impulse = false; | 473 i->second.keepalive_impulse = false; |
468 } | 474 } |
469 | 475 |
470 // OnKeepaliveImpulseCheck() is always called in constructor, but in unit | 476 // OnKeepaliveImpulseCheck() is always called in constructor, but in unit |
471 // tests there will be no message loop. In that event don't schedule tasks. | 477 // tests there will be no message loop. In that event don't schedule tasks. |
472 if (base::MessageLoop::current()) { | 478 if (base::MessageLoop::current()) { |
473 base::MessageLoop::current()->PostDelayedTask( | 479 base::MessageLoop::current()->PostDelayedTask( |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 } | 895 } |
890 | 896 |
891 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { | 897 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { |
892 // Keep in sync with duplicate in extension_info_map.cc. | 898 // Keep in sync with duplicate in extension_info_map.cc. |
893 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | 899 ExtensionService* service = ExtensionSystem::GetForBrowserContext( |
894 GetBrowserContext())->extension_service(); | 900 GetBrowserContext())->extension_service(); |
895 return extension_util::IsIncognitoEnabled(extension->id(), service); | 901 return extension_util::IsIncognitoEnabled(extension->id(), service); |
896 } | 902 } |
897 | 903 |
898 } // namespace extensions | 904 } // namespace extensions |
OLD | NEW |