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 "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | |
10 #include <map> | 9 #include <map> |
11 #include <string> | 10 #include <string> |
12 | 11 |
13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
14 #include "base/guid.h" | 13 #include "base/guid.h" |
15 #include "base/location.h" | 14 #include "base/location.h" |
16 #include "base/macros.h" | 15 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
18 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
19 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
20 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
21 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
23 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
24 #include "base/time/time.h" | 23 #include "base/time/time.h" |
25 #include "content/browser/bad_message.h" | 24 #include "content/browser/bad_message.h" |
26 #include "content/browser/child_process_security_policy_impl.h" | 25 #include "content/browser/child_process_security_policy_impl.h" |
27 #include "content/browser/message_port_message_filter.h" | 26 #include "content/browser/message_port_message_filter.h" |
28 #include "content/browser/message_port_service.h" | 27 #include "content/browser/message_port_service.h" |
29 #include "content/browser/service_worker/embedded_worker_instance.h" | 28 #include "content/browser/service_worker/embedded_worker_instance.h" |
30 #include "content/browser/service_worker/embedded_worker_registry.h" | 29 #include "content/browser/service_worker/embedded_worker_registry.h" |
31 #include "content/browser/service_worker/service_worker_client_navigation_utils.
h" | 30 #include "content/browser/service_worker/service_worker_client_utils.h" |
32 #include "content/browser/service_worker/service_worker_context_core.h" | 31 #include "content/browser/service_worker/service_worker_context_core.h" |
33 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 32 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
34 #include "content/browser/service_worker/service_worker_metrics.h" | 33 #include "content/browser/service_worker/service_worker_metrics.h" |
35 #include "content/browser/service_worker/service_worker_registration.h" | 34 #include "content/browser/service_worker/service_worker_registration.h" |
36 #include "content/common/service_worker/service_worker_messages.h" | 35 #include "content/common/service_worker/service_worker_messages.h" |
37 #include "content/common/service_worker/service_worker_type_converters.h" | 36 #include "content/common/service_worker/service_worker_type_converters.h" |
38 #include "content/common/service_worker/service_worker_utils.h" | 37 #include "content/common/service_worker/service_worker_utils.h" |
39 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
40 #include "content/public/browser/content_browser_client.h" | 39 #include "content/public/browser/content_browser_client.h" |
41 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/common/background_sync.mojom.h" | 41 #include "content/public/common/background_sync.mojom.h" |
43 #include "content/public/common/content_client.h" | 42 #include "content/public/common/content_client.h" |
44 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
45 #include "content/public/common/result_codes.h" | 44 #include "content/public/common/result_codes.h" |
46 #include "content/public/common/service_registry.h" | 45 #include "content/public/common/service_registry.h" |
47 #include "mojo/common/common_type_converters.h" | 46 #include "mojo/common/common_type_converters.h" |
48 #include "mojo/common/url_type_converters.h" | 47 #include "mojo/common/url_type_converters.h" |
49 #include "net/http/http_response_headers.h" | 48 #include "net/http/http_response_headers.h" |
50 #include "net/http/http_response_info.h" | 49 #include "net/http/http_response_info.h" |
51 | 50 |
52 namespace content { | 51 namespace content { |
53 | 52 |
54 using StatusCallback = ServiceWorkerVersion::StatusCallback; | 53 using StatusCallback = ServiceWorkerVersion::StatusCallback; |
55 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; | |
56 using GetClientsCallback = | |
57 base::Callback<void(scoped_ptr<ServiceWorkerClients>)>; | |
58 | 54 |
59 namespace { | 55 namespace { |
60 | 56 |
61 // Time to wait until stopping an idle worker. | 57 // Time to wait until stopping an idle worker. |
62 const int kIdleWorkerTimeoutSeconds = 30; | 58 const int kIdleWorkerTimeoutSeconds = 30; |
63 | 59 |
64 // Default delay for scheduled update. | 60 // Default delay for scheduled update. |
65 const int kUpdateDelaySeconds = 1; | 61 const int kUpdateDelaySeconds = 1; |
66 | 62 |
67 // Timeout for waiting for a response to a ping. | 63 // Timeout for waiting for a response to a ping. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return false; | 188 return false; |
193 return base::TimeTicks().Now() >= expiration; | 189 return base::TimeTicks().Now() >= expiration; |
194 } | 190 } |
195 | 191 |
196 base::TimeDelta GetTickDuration(const base::TimeTicks& time) { | 192 base::TimeDelta GetTickDuration(const base::TimeTicks& time) { |
197 if (time.is_null()) | 193 if (time.is_null()) |
198 return base::TimeDelta(); | 194 return base::TimeDelta(); |
199 return base::TimeTicks().Now() - time; | 195 return base::TimeTicks().Now() - time; |
200 } | 196 } |
201 | 197 |
202 void OnGetWindowClientsFromUI( | |
203 // The tuple contains process_id, frame_id, client_uuid. | |
204 const std::vector<base::Tuple<int, int, std::string>>& clients_info, | |
205 const GURL& script_url, | |
206 const GetClientsCallback& callback) { | |
207 scoped_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients); | |
208 | |
209 for (const auto& it : clients_info) { | |
210 ServiceWorkerClientInfo info = | |
211 ServiceWorkerProviderHost::GetWindowClientInfoOnUI(base::get<0>(it), | |
212 base::get<1>(it)); | |
213 | |
214 // If the request to the provider_host returned an empty | |
215 // ServiceWorkerClientInfo, that means that it wasn't possible to associate | |
216 // it with a valid RenderFrameHost. It might be because the frame was killed | |
217 // or navigated in between. | |
218 if (info.IsEmpty()) | |
219 continue; | |
220 | |
221 // We can get info for a frame that was navigating end ended up with a | |
222 // different URL than expected. In such case, we should make sure to not | |
223 // expose cross-origin WindowClient. | |
224 if (info.url.GetOrigin() != script_url.GetOrigin()) | |
225 continue; | |
226 | |
227 info.client_uuid = base::get<2>(it); | |
228 clients->push_back(info); | |
229 } | |
230 | |
231 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
232 base::Bind(callback, base::Passed(&clients))); | |
233 } | |
234 | |
235 void AddWindowClient( | |
236 ServiceWorkerProviderHost* host, | |
237 std::vector<base::Tuple<int, int, std::string>>* client_info) { | |
238 if (host->client_type() != blink::WebServiceWorkerClientTypeWindow) | |
239 return; | |
240 client_info->push_back(base::MakeTuple(host->process_id(), host->frame_id(), | |
241 host->client_uuid())); | |
242 } | |
243 | |
244 void AddNonWindowClient(ServiceWorkerProviderHost* host, | |
245 const ServiceWorkerClientQueryOptions& options, | |
246 ServiceWorkerClients* clients) { | |
247 blink::WebServiceWorkerClientType host_client_type = host->client_type(); | |
248 if (host_client_type == blink::WebServiceWorkerClientTypeWindow) | |
249 return; | |
250 if (options.client_type != blink::WebServiceWorkerClientTypeAll && | |
251 options.client_type != host_client_type) | |
252 return; | |
253 | |
254 ServiceWorkerClientInfo client_info(blink::WebPageVisibilityStateHidden, | |
255 false, // is_focused | |
256 host->document_url(), | |
257 REQUEST_CONTEXT_FRAME_TYPE_NONE, | |
258 base::TimeTicks(), host_client_type); | |
259 client_info.client_uuid = host->client_uuid(); | |
260 clients->push_back(client_info); | |
261 } | |
262 | |
263 bool IsInstalled(ServiceWorkerVersion::Status status) { | 198 bool IsInstalled(ServiceWorkerVersion::Status status) { |
264 switch (status) { | 199 switch (status) { |
265 case ServiceWorkerVersion::NEW: | 200 case ServiceWorkerVersion::NEW: |
266 case ServiceWorkerVersion::INSTALLING: | 201 case ServiceWorkerVersion::INSTALLING: |
267 case ServiceWorkerVersion::REDUNDANT: | 202 case ServiceWorkerVersion::REDUNDANT: |
268 return false; | 203 return false; |
269 case ServiceWorkerVersion::INSTALLED: | 204 case ServiceWorkerVersion::INSTALLED: |
270 case ServiceWorkerVersion::ACTIVATING: | 205 case ServiceWorkerVersion::ACTIVATING: |
271 case ServiceWorkerVersion::ACTIVATED: | 206 case ServiceWorkerVersion::ACTIVATED: |
272 return true; | 207 return true; |
273 } | 208 } |
274 NOTREACHED() << "Unexpected status: " << status; | 209 NOTREACHED() << "Unexpected status: " << status; |
275 return false; | 210 return false; |
276 } | 211 } |
277 | 212 |
278 struct ServiceWorkerClientInfoSortMRU { | |
279 bool operator()(const ServiceWorkerClientInfo& a, | |
280 const ServiceWorkerClientInfo& b) const { | |
281 return a.last_focus_time > b.last_focus_time; | |
282 } | |
283 }; | |
284 | |
285 } // namespace | 213 } // namespace |
286 | 214 |
287 const int ServiceWorkerVersion::kTimeoutTimerDelaySeconds = 30; | 215 const int ServiceWorkerVersion::kTimeoutTimerDelaySeconds = 30; |
288 const int ServiceWorkerVersion::kStartInstalledWorkerTimeoutSeconds = 10; | 216 const int ServiceWorkerVersion::kStartInstalledWorkerTimeoutSeconds = 10; |
289 const int ServiceWorkerVersion::kStartNewWorkerTimeoutMinutes = 5; | 217 const int ServiceWorkerVersion::kStartNewWorkerTimeoutMinutes = 5; |
290 const int ServiceWorkerVersion::kRequestTimeoutMinutes = 5; | 218 const int ServiceWorkerVersion::kRequestTimeoutMinutes = 5; |
291 const int ServiceWorkerVersion::kStopWorkerTimeoutSeconds = 5; | 219 const int ServiceWorkerVersion::kStopWorkerTimeoutSeconds = 5; |
292 | 220 |
293 class ServiceWorkerVersion::Metrics { | 221 class ServiceWorkerVersion::Metrics { |
294 public: | 222 public: |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 } | 1106 } |
1179 } | 1107 } |
1180 | 1108 |
1181 void ServiceWorkerVersion::OnGetClients( | 1109 void ServiceWorkerVersion::OnGetClients( |
1182 int request_id, | 1110 int request_id, |
1183 const ServiceWorkerClientQueryOptions& options) { | 1111 const ServiceWorkerClientQueryOptions& options) { |
1184 TRACE_EVENT_ASYNC_BEGIN2( | 1112 TRACE_EVENT_ASYNC_BEGIN2( |
1185 "ServiceWorker", "ServiceWorkerVersion::OnGetClients", request_id, | 1113 "ServiceWorker", "ServiceWorkerVersion::OnGetClients", request_id, |
1186 "client_type", options.client_type, "include_uncontrolled", | 1114 "client_type", options.client_type, "include_uncontrolled", |
1187 options.include_uncontrolled); | 1115 options.include_uncontrolled); |
1188 | 1116 service_worker_client_utils::GetClients( |
1189 ServiceWorkerClients clients; | 1117 weak_factory_.GetWeakPtr(), options, |
1190 if (controllee_map_.empty() && !options.include_uncontrolled) { | 1118 base::Bind(&ServiceWorkerVersion::OnGetClientsFinished, |
1191 OnGetClientsFinished(request_id, &clients); | 1119 weak_factory_.GetWeakPtr(), request_id)); |
1192 return; | |
1193 } | |
1194 | |
1195 // For Window clients we want to query the info on the UI thread first. | |
1196 if (options.client_type == blink::WebServiceWorkerClientTypeWindow || | |
1197 options.client_type == blink::WebServiceWorkerClientTypeAll) { | |
1198 GetWindowClients(request_id, options); | |
1199 return; | |
1200 } | |
1201 | |
1202 GetNonWindowClients(request_id, options, &clients); | |
1203 OnGetClientsFinished(request_id, &clients); | |
1204 } | 1120 } |
1205 | 1121 |
1206 void ServiceWorkerVersion::OnGetClientsFinished(int request_id, | 1122 void ServiceWorkerVersion::OnGetClientsFinished(int request_id, |
1207 ServiceWorkerClients* clients) { | 1123 ServiceWorkerClients* clients) { |
1208 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1124 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1209 TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::OnGetClients", | 1125 TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::OnGetClients", |
1210 request_id, "The number of clients", clients->size()); | 1126 request_id, "The number of clients", clients->size()); |
1211 | 1127 |
1212 // When Clients.matchAll() is called on the script evaluation phase, the | 1128 // When Clients.matchAll() is called on the script evaluation phase, the |
1213 // running status can be STARTING here. | 1129 // running status can be STARTING here. |
1214 if (running_status() != STARTING && running_status() != RUNNING) | 1130 if (running_status() != STARTING && running_status() != RUNNING) |
1215 return; | 1131 return; |
1216 | 1132 |
1217 // Sort clients so that the most recently active tab is in the front. | |
1218 std::sort(clients->begin(), clients->end(), ServiceWorkerClientInfoSortMRU()); | |
1219 embedded_worker_->SendMessage( | 1133 embedded_worker_->SendMessage( |
1220 ServiceWorkerMsg_DidGetClients(request_id, *clients)); | 1134 ServiceWorkerMsg_DidGetClients(request_id, *clients)); |
1221 } | 1135 } |
1222 | 1136 |
1223 void ServiceWorkerVersion::OnActivateEventFinished( | 1137 void ServiceWorkerVersion::OnActivateEventFinished( |
1224 int request_id, | 1138 int request_id, |
1225 blink::WebServiceWorkerEventResult result) { | 1139 blink::WebServiceWorkerEventResult result) { |
1226 DCHECK(ACTIVATING == status() || | 1140 DCHECK(ACTIVATING == status() || |
1227 REDUNDANT == status()) << status(); | 1141 REDUNDANT == status()) << status(); |
1228 TRACE_EVENT0("ServiceWorker", | 1142 TRACE_EVENT0("ServiceWorker", |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 // possible to receive such requests since the renderer-side checks are | 1338 // possible to receive such requests since the renderer-side checks are |
1425 // slightly different. For example, the view-source scheme will not be | 1339 // slightly different. For example, the view-source scheme will not be |
1426 // filtered out by Blink. | 1340 // filtered out by Blink. |
1427 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( | 1341 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( |
1428 embedded_worker_->process_id(), url)) { | 1342 embedded_worker_->process_id(), url)) { |
1429 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError( | 1343 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError( |
1430 request_id, url.spec() + " cannot be opened.")); | 1344 request_id, url.spec() + " cannot be opened.")); |
1431 return; | 1345 return; |
1432 } | 1346 } |
1433 | 1347 |
1434 service_worker_client_navigation_utils::OpenWindow( | 1348 service_worker_client_utils::OpenWindow( |
1435 url, script_url_, embedded_worker_->process_id(), context_, | 1349 url, script_url_, embedded_worker_->process_id(), context_, |
1436 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished, | 1350 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished, |
1437 weak_factory_.GetWeakPtr(), request_id)); | 1351 weak_factory_.GetWeakPtr(), request_id)); |
1438 } | 1352 } |
1439 | 1353 |
1440 void ServiceWorkerVersion::OnOpenWindowFinished( | 1354 void ServiceWorkerVersion::OnOpenWindowFinished( |
1441 int request_id, | 1355 int request_id, |
1442 ServiceWorkerStatusCode status, | 1356 ServiceWorkerStatusCode status, |
1443 const std::string& client_uuid, | 1357 const std::string& client_uuid, |
1444 const ServiceWorkerClientInfo& client_info) { | 1358 const ServiceWorkerClientInfo& client_info) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 } | 1509 } |
1596 | 1510 |
1597 ServiceWorkerProviderHost* provider_host = | 1511 ServiceWorkerProviderHost* provider_host = |
1598 context_->GetProviderHostByClientID(client_uuid); | 1512 context_->GetProviderHostByClientID(client_uuid); |
1599 if (!provider_host || provider_host->active_version() != this) { | 1513 if (!provider_host || provider_host->active_version() != this) { |
1600 embedded_worker_->SendMessage( | 1514 embedded_worker_->SendMessage( |
1601 ServiceWorkerMsg_NavigateClientError(request_id, url)); | 1515 ServiceWorkerMsg_NavigateClientError(request_id, url)); |
1602 return; | 1516 return; |
1603 } | 1517 } |
1604 | 1518 |
1605 service_worker_client_navigation_utils::NavigateClient( | 1519 service_worker_client_utils::NavigateClient( |
1606 url, script_url_, provider_host->process_id(), provider_host->frame_id(), | 1520 url, script_url_, provider_host->process_id(), provider_host->frame_id(), |
1607 context_, base::Bind(&ServiceWorkerVersion::OnNavigateClientFinished, | 1521 context_, base::Bind(&ServiceWorkerVersion::OnNavigateClientFinished, |
1608 weak_factory_.GetWeakPtr(), request_id)); | 1522 weak_factory_.GetWeakPtr(), request_id)); |
1609 } | 1523 } |
1610 | 1524 |
1611 void ServiceWorkerVersion::OnNavigateClientFinished( | 1525 void ServiceWorkerVersion::OnNavigateClientFinished( |
1612 int request_id, | 1526 int request_id, |
1613 ServiceWorkerStatusCode status, | 1527 ServiceWorkerStatusCode status, |
1614 const std::string& client_uuid, | 1528 const std::string& client_uuid, |
1615 const ServiceWorkerClientInfo& client_info) { | 1529 const ServiceWorkerClientInfo& client_info) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 if (!timeout_timer_.IsRunning()) | 1676 if (!timeout_timer_.IsRunning()) |
1763 StartTimeoutTimer(); | 1677 StartTimeoutTimer(); |
1764 if (running_status() == STOPPED) { | 1678 if (running_status() == STOPPED) { |
1765 embedded_worker_->Start( | 1679 embedded_worker_->Start( |
1766 version_id_, scope_, script_url_, | 1680 version_id_, scope_, script_url_, |
1767 base::Bind(&ServiceWorkerVersion::OnStartSentAndScriptEvaluated, | 1681 base::Bind(&ServiceWorkerVersion::OnStartSentAndScriptEvaluated, |
1768 weak_factory_.GetWeakPtr())); | 1682 weak_factory_.GetWeakPtr())); |
1769 } | 1683 } |
1770 } | 1684 } |
1771 | 1685 |
1772 void ServiceWorkerVersion::GetWindowClients( | |
1773 int request_id, | |
1774 const ServiceWorkerClientQueryOptions& options) { | |
1775 DCHECK(options.client_type == blink::WebServiceWorkerClientTypeWindow || | |
1776 options.client_type == blink::WebServiceWorkerClientTypeAll); | |
1777 | |
1778 std::vector<base::Tuple<int, int, std::string>> clients_info; | |
1779 if (!options.include_uncontrolled) { | |
1780 for (auto& controllee : controllee_map_) | |
1781 AddWindowClient(controllee.second, &clients_info); | |
1782 } else if (context_) { | |
1783 for (auto it = | |
1784 context_->GetClientProviderHostIterator(script_url_.GetOrigin()); | |
1785 !it->IsAtEnd(); it->Advance()) { | |
1786 AddWindowClient(it->GetProviderHost(), &clients_info); | |
1787 } | |
1788 } | |
1789 | |
1790 if (clients_info.empty()) { | |
1791 DidGetWindowClients(request_id, options, | |
1792 make_scoped_ptr(new ServiceWorkerClients)); | |
1793 return; | |
1794 } | |
1795 | |
1796 BrowserThread::PostTask( | |
1797 BrowserThread::UI, FROM_HERE, | |
1798 base::Bind(&OnGetWindowClientsFromUI, clients_info, script_url_, | |
1799 base::Bind(&ServiceWorkerVersion::DidGetWindowClients, | |
1800 weak_factory_.GetWeakPtr(), request_id, options))); | |
1801 } | |
1802 | |
1803 void ServiceWorkerVersion::DidGetWindowClients( | |
1804 int request_id, | |
1805 const ServiceWorkerClientQueryOptions& options, | |
1806 scoped_ptr<ServiceWorkerClients> clients) { | |
1807 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
1808 if (options.client_type == blink::WebServiceWorkerClientTypeAll) | |
1809 GetNonWindowClients(request_id, options, clients.get()); | |
1810 OnGetClientsFinished(request_id, clients.get()); | |
1811 } | |
1812 | |
1813 void ServiceWorkerVersion::GetNonWindowClients( | |
1814 int request_id, | |
1815 const ServiceWorkerClientQueryOptions& options, | |
1816 ServiceWorkerClients* clients) { | |
1817 if (!options.include_uncontrolled) { | |
1818 for (auto& controllee : controllee_map_) { | |
1819 AddNonWindowClient(controllee.second, options, clients); | |
1820 } | |
1821 } else if (context_) { | |
1822 for (auto it = | |
1823 context_->GetClientProviderHostIterator(script_url_.GetOrigin()); | |
1824 !it->IsAtEnd(); it->Advance()) { | |
1825 AddNonWindowClient(it->GetProviderHost(), options, clients); | |
1826 } | |
1827 } | |
1828 } | |
1829 | |
1830 void ServiceWorkerVersion::StartTimeoutTimer() { | 1686 void ServiceWorkerVersion::StartTimeoutTimer() { |
1831 DCHECK(!timeout_timer_.IsRunning()); | 1687 DCHECK(!timeout_timer_.IsRunning()); |
1832 | 1688 |
1833 if (embedded_worker_->devtools_attached()) { | 1689 if (embedded_worker_->devtools_attached()) { |
1834 // Don't record the startup time metric once DevTools is attached. | 1690 // Don't record the startup time metric once DevTools is attached. |
1835 ClearTick(&start_time_); | 1691 ClearTick(&start_time_); |
1836 skip_recording_startup_time_ = true; | 1692 skip_recording_startup_time_ = true; |
1837 } else { | 1693 } else { |
1838 RestartTick(&start_time_); | 1694 RestartTick(&start_time_); |
1839 skip_recording_startup_time_ = false; | 1695 skip_recording_startup_time_ = false; |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2277 void ServiceWorkerVersion::OnBeginEvent() { | 2133 void ServiceWorkerVersion::OnBeginEvent() { |
2278 if (should_exclude_from_uma_ || running_status() != RUNNING || | 2134 if (should_exclude_from_uma_ || running_status() != RUNNING || |
2279 idle_time_.is_null()) { | 2135 idle_time_.is_null()) { |
2280 return; | 2136 return; |
2281 } | 2137 } |
2282 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 2138 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
2283 idle_time_); | 2139 idle_time_); |
2284 } | 2140 } |
2285 | 2141 |
2286 } // namespace content | 2142 } // namespace content |
OLD | NEW |