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 <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( | 1330 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( |
1331 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, | 1331 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, |
1332 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); | 1332 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); |
1333 } | 1333 } |
1334 | 1334 |
1335 void ServiceWorkerVersion::OnPongFromWorker() { | 1335 void ServiceWorkerVersion::OnPongFromWorker() { |
1336 ping_controller_->OnPongReceived(); | 1336 ping_controller_->OnPongReceived(); |
1337 } | 1337 } |
1338 | 1338 |
1339 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( | 1339 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( |
1340 const std::vector<GURL>& sub_scopes) { | 1340 const std::vector<GURL>& sub_scopes, |
| 1341 const std::vector<GURL>& origins) { |
1341 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); | 1342 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); |
1342 // Renderer should have already verified all these urls are inside the | 1343 // Renderer should have already verified all these urls are inside the |
1343 // worker's scope, but verify again here on the browser process side. | 1344 // worker's scope, but verify again here on the browser process side. |
1344 GURL origin = scope_.GetOrigin(); | 1345 GURL origin = scope_.GetOrigin(); |
1345 std::string scope_path = scope_.path(); | 1346 std::string scope_path = scope_.path(); |
1346 for (const GURL& url : sub_scopes) { | 1347 for (const GURL& url : sub_scopes) { |
1347 if (!url.is_valid() || url.GetOrigin() != origin || | 1348 if (!url.is_valid() || url.GetOrigin() != origin || |
1348 !base::StartsWith(url.path(), scope_path, | 1349 !base::StartsWith(url.path(), scope_path, |
1349 base::CompareCase::SENSITIVE)) { | 1350 base::CompareCase::SENSITIVE)) { |
1350 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | 1351 DVLOG(1) << "Received unexpected invalid URL from renderer process."; |
1351 BrowserThread::PostTask( | 1352 BrowserThread::PostTask( |
1352 BrowserThread::UI, FROM_HERE, | 1353 BrowserThread::UI, FROM_HERE, |
1353 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), | 1354 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), |
1354 RESULT_CODE_KILLED_BAD_MESSAGE)); | 1355 RESULT_CODE_KILLED_BAD_MESSAGE)); |
1355 return; | 1356 return; |
1356 } | 1357 } |
1357 } | 1358 } |
1358 foreign_fetch_scopes_.insert(foreign_fetch_scopes_.end(), sub_scopes.begin(), | 1359 for (const GURL& url : origins) { |
1359 sub_scopes.end()); | 1360 if (!url.is_valid()) { |
| 1361 DVLOG(1) << "Received unexpected invalid URL from renderer process."; |
| 1362 BrowserThread::PostTask( |
| 1363 BrowserThread::UI, FROM_HERE, |
| 1364 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), |
| 1365 RESULT_CODE_KILLED_BAD_MESSAGE)); |
| 1366 return; |
| 1367 } |
| 1368 } |
| 1369 set_foreign_fetch_scopes(sub_scopes); |
| 1370 set_foreign_fetch_origins(origins); |
1360 } | 1371 } |
1361 | 1372 |
1362 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( | 1373 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( |
1363 const StatusCallback& callback, | 1374 const StatusCallback& callback, |
1364 ServiceWorkerStatusCode status, | 1375 ServiceWorkerStatusCode status, |
1365 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 1376 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
1366 scoped_refptr<ServiceWorkerRegistration> protect = registration; | 1377 scoped_refptr<ServiceWorkerRegistration> protect = registration; |
1367 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 1378 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
1368 // When the registration has already been deleted from the storage but its | 1379 // When the registration has already been deleted from the storage but its |
1369 // active worker is still controlling clients, the event should be | 1380 // active worker is still controlling clients, the event should be |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 void ServiceWorkerVersion::OnBeginEvent() { | 1837 void ServiceWorkerVersion::OnBeginEvent() { |
1827 if (should_exclude_from_uma_ || running_status() != RUNNING || | 1838 if (should_exclude_from_uma_ || running_status() != RUNNING || |
1828 idle_time_.is_null()) { | 1839 idle_time_.is_null()) { |
1829 return; | 1840 return; |
1830 } | 1841 } |
1831 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1842 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1832 idle_time_); | 1843 idle_time_); |
1833 } | 1844 } |
1834 | 1845 |
1835 } // namespace content | 1846 } // namespace content |
OLD | NEW |