| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 bool is_closing; | 135 bool is_closing; |
| 136 | 136 |
| 137 // Stores the value of the incremented | 137 // Stores the value of the incremented |
| 138 // ProcessManager::last_background_close_sequence_id_ whenever the extension | 138 // ProcessManager::last_background_close_sequence_id_ whenever the extension |
| 139 // is active. A copy of the ID is also passed in the callbacks and IPC | 139 // is active. A copy of the ID is also passed in the callbacks and IPC |
| 140 // messages leading up to CloseLazyBackgroundPageNow. The process is aborted | 140 // messages leading up to CloseLazyBackgroundPageNow. The process is aborted |
| 141 // if the IDs ever differ due to new activity. | 141 // if the IDs ever differ due to new activity. |
| 142 uint64_t close_sequence_id; | 142 uint64_t close_sequence_id; |
| 143 | 143 |
| 144 // Keeps track of when this page was last suspended. Used for perf metrics. | 144 // Keeps track of when this page was last suspended. Used for perf metrics. |
| 145 linked_ptr<base::ElapsedTimer> since_suspended; | 145 std::unique_ptr<base::ElapsedTimer> since_suspended; |
| 146 | 146 |
| 147 BackgroundPageData() | 147 BackgroundPageData() |
| 148 : lazy_keepalive_count(0), | 148 : lazy_keepalive_count(0), |
| 149 keepalive_impulse(false), | 149 keepalive_impulse(false), |
| 150 previous_keepalive_impulse(false), | 150 previous_keepalive_impulse(false), |
| 151 is_closing(false), | 151 is_closing(false), |
| 152 close_sequence_id(0) {} | 152 close_sequence_id(0) {} |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Data of a RenderFrameHost associated with an extension. | 155 // Data of a RenderFrameHost associated with an extension. |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 observer_list_, | 707 observer_list_, |
| 708 OnBackgroundHostStartup(extension.get())); | 708 OnBackgroundHostStartup(extension.get())); |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 | 711 |
| 712 void ProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { | 712 void ProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { |
| 713 DCHECK_EQ(browser_context_, host->browser_context()); | 713 DCHECK_EQ(browser_context_, host->browser_context()); |
| 714 background_hosts_.insert(host); | 714 background_hosts_.insert(host); |
| 715 | 715 |
| 716 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) { | 716 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) { |
| 717 linked_ptr<base::ElapsedTimer> since_suspended( | 717 std::unique_ptr<base::ElapsedTimer> since_suspended = std::move( |
| 718 background_page_data_[host->extension()->id()]. | 718 background_page_data_[host->extension()->id()].since_suspended); |
| 719 since_suspended.release()); | |
| 720 if (since_suspended.get()) { | 719 if (since_suspended.get()) { |
| 721 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", | 720 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageIdleTime", |
| 722 since_suspended->Elapsed()); | 721 since_suspended->Elapsed()); |
| 723 } | 722 } |
| 724 } | 723 } |
| 725 FOR_EACH_OBSERVER(ProcessManagerObserver, observer_list_, | 724 FOR_EACH_OBSERVER(ProcessManagerObserver, observer_list_, |
| 726 OnBackgroundHostCreated(host)); | 725 OnBackgroundHostCreated(host)); |
| 727 } | 726 } |
| 728 | 727 |
| 729 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { | 728 void ProcessManager::CloseBackgroundHost(ExtensionHost* host) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 987 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 989 BrowserContext* original_context = | 988 BrowserContext* original_context = |
| 990 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); | 989 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); |
| 991 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); | 990 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); |
| 992 } | 991 } |
| 993 | 992 |
| 994 return ProcessManager::GetSiteInstanceForURL(url); | 993 return ProcessManager::GetSiteInstanceForURL(url); |
| 995 } | 994 } |
| 996 | 995 |
| 997 } // namespace extensions | 996 } // namespace extensions |
| OLD | NEW |