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 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( | 1265 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( |
1266 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, | 1266 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, |
1267 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); | 1267 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); |
1268 } | 1268 } |
1269 | 1269 |
1270 void ServiceWorkerVersion::OnPongFromWorker() { | 1270 void ServiceWorkerVersion::OnPongFromWorker() { |
1271 ping_controller_->OnPongReceived(); | 1271 ping_controller_->OnPongReceived(); |
1272 } | 1272 } |
1273 | 1273 |
1274 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( | 1274 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( |
1275 const std::vector<GURL>& sub_scopes) { | 1275 const std::vector<GURL>& sub_scopes, |
| 1276 const std::vector<url::Origin>& origins) { |
1276 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); | 1277 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); |
1277 // Renderer should have already verified all these urls are inside the | 1278 // Renderer should have already verified all these urls are inside the |
1278 // worker's scope, but verify again here on the browser process side. | 1279 // worker's scope, but verify again here on the browser process side. |
1279 GURL origin = scope_.GetOrigin(); | 1280 GURL origin = scope_.GetOrigin(); |
1280 std::string scope_path = scope_.path(); | 1281 std::string scope_path = scope_.path(); |
1281 for (const GURL& url : sub_scopes) { | 1282 for (const GURL& url : sub_scopes) { |
1282 if (!url.is_valid() || url.GetOrigin() != origin || | 1283 if (!url.is_valid() || url.GetOrigin() != origin || |
1283 !base::StartsWith(url.path(), scope_path, | 1284 !base::StartsWith(url.path(), scope_path, |
1284 base::CompareCase::SENSITIVE)) { | 1285 base::CompareCase::SENSITIVE)) { |
1285 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | 1286 DVLOG(1) << "Received unexpected invalid URL from renderer process."; |
1286 BrowserThread::PostTask( | 1287 BrowserThread::PostTask( |
1287 BrowserThread::UI, FROM_HERE, | 1288 BrowserThread::UI, FROM_HERE, |
1288 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), | 1289 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), |
1289 RESULT_CODE_KILLED_BAD_MESSAGE)); | 1290 RESULT_CODE_KILLED_BAD_MESSAGE)); |
1290 return; | 1291 return; |
1291 } | 1292 } |
1292 } | 1293 } |
1293 foreign_fetch_scopes_.insert(foreign_fetch_scopes_.end(), sub_scopes.begin(), | 1294 for (const url::Origin& url : origins) { |
1294 sub_scopes.end()); | 1295 if (url.unique()) { |
| 1296 DVLOG(1) << "Received unexpected unique origin from renderer process."; |
| 1297 BrowserThread::PostTask( |
| 1298 BrowserThread::UI, FROM_HERE, |
| 1299 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), |
| 1300 RESULT_CODE_KILLED_BAD_MESSAGE)); |
| 1301 return; |
| 1302 } |
| 1303 } |
| 1304 set_foreign_fetch_scopes(sub_scopes); |
| 1305 set_foreign_fetch_origins(origins); |
1295 } | 1306 } |
1296 | 1307 |
1297 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( | 1308 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( |
1298 const StatusCallback& callback, | 1309 const StatusCallback& callback, |
1299 ServiceWorkerStatusCode status, | 1310 ServiceWorkerStatusCode status, |
1300 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 1311 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
1301 scoped_refptr<ServiceWorkerRegistration> protect = registration; | 1312 scoped_refptr<ServiceWorkerRegistration> protect = registration; |
1302 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 1313 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
1303 // When the registration has already been deleted from the storage but its | 1314 // When the registration has already been deleted from the storage but its |
1304 // active worker is still controlling clients, the event should be | 1315 // active worker is still controlling clients, the event should be |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 void ServiceWorkerVersion::OnBeginEvent() { | 1763 void ServiceWorkerVersion::OnBeginEvent() { |
1753 if (should_exclude_from_uma_ || running_status() != RUNNING || | 1764 if (should_exclude_from_uma_ || running_status() != RUNNING || |
1754 idle_time_.is_null()) { | 1765 idle_time_.is_null()) { |
1755 return; | 1766 return; |
1756 } | 1767 } |
1757 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1768 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1758 idle_time_); | 1769 idle_time_); |
1759 } | 1770 } |
1760 | 1771 |
1761 } // namespace content | 1772 } // namespace content |
OLD | NEW |