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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( | 1299 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( |
1300 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, | 1300 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, |
1301 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); | 1301 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); |
1302 } | 1302 } |
1303 | 1303 |
1304 void ServiceWorkerVersion::OnPongFromWorker() { | 1304 void ServiceWorkerVersion::OnPongFromWorker() { |
1305 ping_controller_->OnPongReceived(); | 1305 ping_controller_->OnPongReceived(); |
1306 } | 1306 } |
1307 | 1307 |
1308 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( | 1308 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( |
1309 const std::vector<GURL>& sub_scopes) { | 1309 const std::vector<GURL>& sub_scopes, |
1310 const std::vector<GURL>& origins) { | |
1310 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); | 1311 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); |
1311 // Renderer should have already verified all these urls are inside the | 1312 // Renderer should have already verified all these urls are inside the |
1312 // worker's scope, but verify again here on the browser process side. | 1313 // worker's scope, but verify again here on the browser process side. |
1313 GURL origin = scope_.GetOrigin(); | 1314 GURL origin = scope_.GetOrigin(); |
1314 std::string scope_path = scope_.path(); | 1315 std::string scope_path = scope_.path(); |
1315 for (const GURL& url : sub_scopes) { | 1316 for (const GURL& url : sub_scopes) { |
1316 if (!url.is_valid() || url.GetOrigin() != origin || | 1317 if (!url.is_valid() || url.GetOrigin() != origin || |
1317 !base::StartsWith(url.path(), scope_path, | 1318 !base::StartsWith(url.path(), scope_path, |
1318 base::CompareCase::SENSITIVE)) { | 1319 base::CompareCase::SENSITIVE)) { |
1319 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | 1320 DVLOG(1) << "Received unexpected invalid URL from renderer process."; |
1320 BrowserThread::PostTask( | 1321 BrowserThread::PostTask( |
1321 BrowserThread::UI, FROM_HERE, | 1322 BrowserThread::UI, FROM_HERE, |
1322 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), | 1323 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), |
1323 RESULT_CODE_KILLED_BAD_MESSAGE)); | 1324 RESULT_CODE_KILLED_BAD_MESSAGE)); |
1324 return; | 1325 return; |
1325 } | 1326 } |
1326 } | 1327 } |
1327 foreign_fetch_scopes_.insert(foreign_fetch_scopes_.end(), sub_scopes.begin(), | 1328 for (const GURL& url : origins) { |
1328 sub_scopes.end()); | 1329 if (!url.is_valid()) { |
1330 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | |
1331 BrowserThread::PostTask( | |
1332 BrowserThread::UI, FROM_HERE, | |
1333 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), | |
1334 RESULT_CODE_KILLED_BAD_MESSAGE)); | |
1335 return; | |
1336 } | |
1337 } | |
1338 set_foreign_fetch_scopes(sub_scopes); | |
falken
2016/02/03 02:17:31
The previous code appended the scopes to the end,
Marijn Kruisselbrink
2016/02/03 17:53:30
Yes, this change is intentional. The spec always s
| |
1339 set_foreign_fetch_origins(origins); | |
1329 } | 1340 } |
1330 | 1341 |
1331 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( | 1342 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( |
1332 const StatusCallback& callback, | 1343 const StatusCallback& callback, |
1333 ServiceWorkerStatusCode status, | 1344 ServiceWorkerStatusCode status, |
1334 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 1345 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
1335 scoped_refptr<ServiceWorkerRegistration> protect = registration; | 1346 scoped_refptr<ServiceWorkerRegistration> protect = registration; |
1336 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { | 1347 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { |
1337 // When the registration has already been deleted from the storage but its | 1348 // When the registration has already been deleted from the storage but its |
1338 // active worker is still controlling clients, the event should be | 1349 // active worker is still controlling clients, the event should be |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 void ServiceWorkerVersion::OnBeginEvent() { | 1806 void ServiceWorkerVersion::OnBeginEvent() { |
1796 if (should_exclude_from_uma_ || running_status() != RUNNING || | 1807 if (should_exclude_from_uma_ || running_status() != RUNNING || |
1797 idle_time_.is_null()) { | 1808 idle_time_.is_null()) { |
1798 return; | 1809 return; |
1799 } | 1810 } |
1800 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 1811 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
1801 idle_time_); | 1812 idle_time_); |
1802 } | 1813 } |
1803 | 1814 |
1804 } // namespace content | 1815 } // namespace content |
OLD | NEW |