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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 424 } |
425 | 425 |
426 int ExtensionProcessManager::DecrementLazyKeepaliveCount( | 426 int ExtensionProcessManager::DecrementLazyKeepaliveCount( |
427 const Extension* extension) { | 427 const Extension* extension) { |
428 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) | 428 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) |
429 return 0; | 429 return 0; |
430 | 430 |
431 int& count = background_page_data_[extension->id()].lazy_keepalive_count; | 431 int& count = background_page_data_[extension->id()].lazy_keepalive_count; |
432 DCHECK_GT(count, 0); | 432 DCHECK_GT(count, 0); |
433 if (--count == 0) { | 433 if (--count == 0) { |
434 MessageLoop::current()->PostDelayedTask( | 434 base::MessageLoop::current()->PostDelayedTask( |
435 FROM_HERE, | 435 FROM_HERE, |
436 base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle, | 436 base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle, |
437 weak_ptr_factory_.GetWeakPtr(), extension->id(), | 437 weak_ptr_factory_.GetWeakPtr(), extension->id(), |
438 ++background_page_data_[extension->id()].close_sequence_id), | 438 ++background_page_data_[extension->id()].close_sequence_id), |
439 event_page_idle_time_); | 439 event_page_idle_time_); |
440 } | 440 } |
441 | 441 |
442 return count; | 442 return count; |
443 } | 443 } |
444 | 444 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 487 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
488 if (host && | 488 if (host && |
489 sequence_id == background_page_data_[extension_id].close_sequence_id) { | 489 sequence_id == background_page_data_[extension_id].close_sequence_id) { |
490 host->render_view_host()->Send(new ExtensionMsg_Suspend(extension_id)); | 490 host->render_view_host()->Send(new ExtensionMsg_Suspend(extension_id)); |
491 } | 491 } |
492 } | 492 } |
493 | 493 |
494 void ExtensionProcessManager::OnSuspendAck(const std::string& extension_id) { | 494 void ExtensionProcessManager::OnSuspendAck(const std::string& extension_id) { |
495 background_page_data_[extension_id].is_closing = true; | 495 background_page_data_[extension_id].is_closing = true; |
496 int sequence_id = background_page_data_[extension_id].close_sequence_id; | 496 int sequence_id = background_page_data_[extension_id].close_sequence_id; |
497 MessageLoop::current()->PostDelayedTask( | 497 base::MessageLoop::current()->PostDelayedTask( |
498 FROM_HERE, | 498 FROM_HERE, |
499 base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, | 499 base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, |
500 weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), | 500 weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), |
501 event_page_suspending_time_); | 501 event_page_suspending_time_); |
502 } | 502 } |
503 | 503 |
504 void ExtensionProcessManager::CloseLazyBackgroundPageNow( | 504 void ExtensionProcessManager::CloseLazyBackgroundPageNow( |
505 const std::string& extension_id, int sequence_id) { | 505 const std::string& extension_id, int sequence_id) { |
506 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 506 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
507 if (host && | 507 if (host && |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 if (service && service->is_ready()) | 893 if (service && service->is_ready()) |
894 CreateBackgroundHostsForProfileStartup(); | 894 CreateBackgroundHostsForProfileStartup(); |
895 } | 895 } |
896 break; | 896 break; |
897 } | 897 } |
898 default: | 898 default: |
899 ExtensionProcessManager::Observe(type, source, details); | 899 ExtensionProcessManager::Observe(type, source, details); |
900 break; | 900 break; |
901 } | 901 } |
902 } | 902 } |
OLD | NEW |