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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 } | 419 } |
420 | 420 |
421 int ExtensionProcessManager::DecrementLazyKeepaliveCount( | 421 int ExtensionProcessManager::DecrementLazyKeepaliveCount( |
422 const Extension* extension) { | 422 const Extension* extension) { |
423 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) | 423 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) |
424 return 0; | 424 return 0; |
425 | 425 |
426 int& count = background_page_data_[extension->id()].lazy_keepalive_count; | 426 int& count = background_page_data_[extension->id()].lazy_keepalive_count; |
427 DCHECK_GT(count, 0); | 427 DCHECK_GT(count, 0); |
428 if (--count == 0) { | 428 if (--count == 0) { |
429 MessageLoop::current()->PostDelayedTask( | 429 base::MessageLoop::current()->PostDelayedTask( |
430 FROM_HERE, | 430 FROM_HERE, |
431 base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle, | 431 base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle, |
432 weak_ptr_factory_.GetWeakPtr(), extension->id(), | 432 weak_ptr_factory_.GetWeakPtr(), |
brettw
2013/04/28 04:26:27
Old way was fine.
| |
433 extension->id(), | |
433 ++background_page_data_[extension->id()].close_sequence_id), | 434 ++background_page_data_[extension->id()].close_sequence_id), |
434 event_page_idle_time_); | 435 event_page_idle_time_); |
435 } | 436 } |
436 | 437 |
437 return count; | 438 return count; |
438 } | 439 } |
439 | 440 |
440 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( | 441 void ExtensionProcessManager::IncrementLazyKeepaliveCountForView( |
441 RenderViewHost* render_view_host) { | 442 RenderViewHost* render_view_host) { |
442 WebContents* web_contents = | 443 WebContents* web_contents = |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 483 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
483 if (host && | 484 if (host && |
484 sequence_id == background_page_data_[extension_id].close_sequence_id) { | 485 sequence_id == background_page_data_[extension_id].close_sequence_id) { |
485 host->render_view_host()->Send(new ExtensionMsg_Suspend(extension_id)); | 486 host->render_view_host()->Send(new ExtensionMsg_Suspend(extension_id)); |
486 } | 487 } |
487 } | 488 } |
488 | 489 |
489 void ExtensionProcessManager::OnSuspendAck(const std::string& extension_id) { | 490 void ExtensionProcessManager::OnSuspendAck(const std::string& extension_id) { |
490 background_page_data_[extension_id].is_closing = true; | 491 background_page_data_[extension_id].is_closing = true; |
491 int sequence_id = background_page_data_[extension_id].close_sequence_id; | 492 int sequence_id = background_page_data_[extension_id].close_sequence_id; |
492 MessageLoop::current()->PostDelayedTask( | 493 base::MessageLoop::current()->PostDelayedTask( |
493 FROM_HERE, | 494 FROM_HERE, |
494 base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, | 495 base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, |
495 weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), | 496 weak_ptr_factory_.GetWeakPtr(), |
497 extension_id, | |
498 sequence_id), | |
496 event_page_suspending_time_); | 499 event_page_suspending_time_); |
497 } | 500 } |
498 | 501 |
499 void ExtensionProcessManager::CloseLazyBackgroundPageNow( | 502 void ExtensionProcessManager::CloseLazyBackgroundPageNow( |
500 const std::string& extension_id, int sequence_id) { | 503 const std::string& extension_id, int sequence_id) { |
501 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 504 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
502 if (host && | 505 if (host && |
503 sequence_id == background_page_data_[extension_id].close_sequence_id) { | 506 sequence_id == background_page_data_[extension_id].close_sequence_id) { |
504 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 507 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
505 if (host) | 508 if (host) |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 if (service && service->is_ready()) | 885 if (service && service->is_ready()) |
883 CreateBackgroundHostsForProfileStartup(); | 886 CreateBackgroundHostsForProfileStartup(); |
884 } | 887 } |
885 break; | 888 break; |
886 } | 889 } |
887 default: | 890 default: |
888 ExtensionProcessManager::Observe(type, source, details); | 891 ExtensionProcessManager::Observe(type, source, details); |
889 break; | 892 break; |
890 } | 893 } |
891 } | 894 } |
OLD | NEW |