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

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

Issue 111563006: Test Keeping NaCl plugins used in app background pages alive when active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 7 years 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/process_manager.h ('k') | ppapi/proxy/plugin_main_nacl.cc » ('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"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return; 414 return;
415 415
416 BackgroundPageData& bd = background_page_data_[extension->id()]; 416 BackgroundPageData& bd = background_page_data_[extension->id()];
417 417
418 if (!bd.keepalive_impulse) { 418 if (!bd.keepalive_impulse) {
419 bd.keepalive_impulse = true; 419 bd.keepalive_impulse = true;
420 if (!bd.previous_keepalive_impulse) { 420 if (!bd.previous_keepalive_impulse) {
421 IncrementLazyKeepaliveCount(extension); 421 IncrementLazyKeepaliveCount(extension);
422 } 422 }
423 } 423 }
424
425 if (!keepalive_impulse_callback_for_testing_.is_null())
426 keepalive_impulse_callback_for_testing_.Run(extension->id());
424 } 427 }
425 428
426 // DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse 429 // DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse
427 // have been made for at least event_page_idle_time_. In the best case an 430 // have been made for at least event_page_idle_time_. In the best case an
428 // impulse was made just before being cleared, and the decrement will occur 431 // impulse was made just before being cleared, and the decrement will occur
429 // event_page_idle_time_ later, causing a 2 * event_page_idle_time_ total time 432 // event_page_idle_time_ later, causing a 2 * event_page_idle_time_ total time
430 // for extension to be shut down based on impulses. Worst case is an impulse 433 // for extension to be shut down based on impulses. Worst case is an impulse
431 // just after a clear, adding one check cycle and resulting in 3x total time. 434 // just after a clear, adding one check cycle and resulting in 3x total time.
432 void ProcessManager::OnKeepaliveImpulseCheck() { 435 void ProcessManager::OnKeepaliveImpulseCheck() {
433 for (BackgroundPageDataMap::iterator i = background_page_data_.begin(); 436 for (BackgroundPageDataMap::iterator i = background_page_data_.begin();
434 i != background_page_data_.end(); 437 i != background_page_data_.end();
435 ++i) { 438 ++i) {
436 if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) 439 if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) {
437 DecrementLazyKeepaliveCount(i->first); 440 DecrementLazyKeepaliveCount(i->first);
441 if (!keepalive_impulse_decrement_callback_for_testing_.is_null())
442 keepalive_impulse_decrement_callback_for_testing_.Run(i->first);
443 }
438 444
439 i->second.previous_keepalive_impulse = i->second.keepalive_impulse; 445 i->second.previous_keepalive_impulse = i->second.keepalive_impulse;
440 i->second.keepalive_impulse = false; 446 i->second.keepalive_impulse = false;
441 } 447 }
442 448
443 // OnKeepaliveImpulseCheck() is always called in constructor, but in unit 449 // OnKeepaliveImpulseCheck() is always called in constructor, but in unit
444 // tests there will be no message loop. In that event don't schedule tasks. 450 // tests there will be no message loop. In that event don't schedule tasks.
445 if (base::MessageLoop::current()) { 451 if (base::MessageLoop::current()) {
446 base::MessageLoop::current()->PostDelayedTask( 452 base::MessageLoop::current()->PostDelayedTask(
447 FROM_HERE, 453 FROM_HERE,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (!service || !service->is_ready()) 552 if (!service || !service->is_ready())
547 return; 553 return;
548 554
549 CreateBackgroundHostsForProfileStartup(); 555 CreateBackgroundHostsForProfileStartup();
550 } 556 }
551 557
552 content::BrowserContext* ProcessManager::GetBrowserContext() const { 558 content::BrowserContext* ProcessManager::GetBrowserContext() const {
553 return site_instance_->GetBrowserContext(); 559 return site_instance_->GetBrowserContext();
554 } 560 }
555 561
562 void ProcessManager::SetKeepaliveImpulseCallbackForTesting(
563 const ImpulseCallbackForTesting& callback) {
564 keepalive_impulse_callback_for_testing_ = callback;
565 }
566
567 void ProcessManager::SetKeepaliveImpulseDecrementCallbackForTesting(
568 const ImpulseCallbackForTesting& callback) {
569 keepalive_impulse_decrement_callback_for_testing_ = callback;
570 }
571
556 void ProcessManager::Observe(int type, 572 void ProcessManager::Observe(int type,
557 const content::NotificationSource& source, 573 const content::NotificationSource& source,
558 const content::NotificationDetails& details) { 574 const content::NotificationDetails& details) {
559 switch (type) { 575 switch (type) {
560 case chrome::NOTIFICATION_EXTENSIONS_READY: 576 case chrome::NOTIFICATION_EXTENSIONS_READY:
561 case chrome::NOTIFICATION_PROFILE_CREATED: { 577 case chrome::NOTIFICATION_PROFILE_CREATED: {
562 // Don't load background hosts now if the loading should be deferred. 578 // Don't load background hosts now if the loading should be deferred.
563 // Instead they will be loaded when a browser window for this profile 579 // Instead they will be loaded when a browser window for this profile
564 // (or an incognito profile from this profile) is ready. 580 // (or an incognito profile from this profile) is ready.
565 if (DeferLoadingBackgroundHosts()) 581 if (DeferLoadingBackgroundHosts())
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 864 }
849 865
850 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { 866 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) {
851 // Keep in sync with duplicate in extension_info_map.cc. 867 // Keep in sync with duplicate in extension_info_map.cc.
852 ExtensionService* service = ExtensionSystem::GetForBrowserContext( 868 ExtensionService* service = ExtensionSystem::GetForBrowserContext(
853 GetBrowserContext())->extension_service(); 869 GetBrowserContext())->extension_service();
854 return extension_util::IsIncognitoEnabled(extension->id(), service); 870 return extension_util::IsIncognitoEnabled(extension->id(), service);
855 } 871 }
856 872
857 } // namespace extensions 873 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/process_manager.h ('k') | ppapi/proxy/plugin_main_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698