Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1255 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient, | 1255 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient, |
| 1256 OnPostMessageToClient) | 1256 OnPostMessageToClient) |
| 1257 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient, | 1257 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient, |
| 1258 OnFocusClient) | 1258 OnFocusClient) |
| 1259 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient) | 1259 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient) |
| 1260 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting, | 1260 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting, |
| 1261 OnSkipWaiting) | 1261 OnSkipWaiting) |
| 1262 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClaimClients, | 1262 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClaimClients, |
| 1263 OnClaimClients) | 1263 OnClaimClients) |
| 1264 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_Pong, OnPongFromWorker) | 1264 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_Pong, OnPongFromWorker) |
| 1265 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterForeignFetchScopes, | |
| 1266 OnRegisterForeignFetchScopes) | |
| 1265 IPC_MESSAGE_UNHANDLED(handled = false) | 1267 IPC_MESSAGE_UNHANDLED(handled = false) |
| 1266 IPC_END_MESSAGE_MAP() | 1268 IPC_END_MESSAGE_MAP() |
| 1267 return handled; | 1269 return handled; |
| 1268 } | 1270 } |
| 1269 | 1271 |
| 1270 void ServiceWorkerVersion::OnStartSentAndScriptEvaluated( | 1272 void ServiceWorkerVersion::OnStartSentAndScriptEvaluated( |
| 1271 ServiceWorkerStatusCode status) { | 1273 ServiceWorkerStatusCode status) { |
| 1272 if (status != SERVICE_WORKER_OK) { | 1274 if (status != SERVICE_WORKER_OK) { |
| 1273 scoped_refptr<ServiceWorkerVersion> protect(this); | 1275 scoped_refptr<ServiceWorkerVersion> protect(this); |
| 1274 RunCallbacks(this, &start_callbacks_, | 1276 RunCallbacks(this, &start_callbacks_, |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1857 | 1859 |
| 1858 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( | 1860 embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError( |
| 1859 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, | 1861 request_id, blink::WebServiceWorkerError::ErrorTypeAbort, |
| 1860 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); | 1862 base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage))); |
| 1861 } | 1863 } |
| 1862 | 1864 |
| 1863 void ServiceWorkerVersion::OnPongFromWorker() { | 1865 void ServiceWorkerVersion::OnPongFromWorker() { |
| 1864 ping_controller_->OnPongReceived(); | 1866 ping_controller_->OnPongReceived(); |
| 1865 } | 1867 } |
| 1866 | 1868 |
| 1869 void ServiceWorkerVersion::OnRegisterForeignFetchScopes( | |
| 1870 const std::vector<GURL>& sub_scopes) { | |
| 1871 DCHECK(status() == INSTALLING || status() == REDUNDANT) << status(); | |
| 1872 // Renderer should have already verified all these urls are inside the workers | |
| 1873 // scope, but verify again here on the browser process side. | |
| 1874 GURL origin = scope_.GetOrigin(); | |
| 1875 std::string scope_path = scope_.path(); | |
| 1876 for (const GURL& url : sub_scopes) { | |
| 1877 if (!url.is_valid() || url.GetOrigin() != origin || | |
| 1878 !base::StartsWith(url.path(), scope_path, | |
| 1879 base::CompareCase::SENSITIVE)) { | |
| 1880 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | |
|
bsittler
2015/10/15 19:37:59
Should there be test coverage for this defense-in-
Marijn Kruisselbrink
2015/10/15 22:19:04
Good point, I added some.
| |
| 1881 BrowserThread::PostTask( | |
| 1882 BrowserThread::UI, FROM_HERE, | |
| 1883 base::Bind(&KillEmbeddedWorkerProcess, embedded_worker_->process_id(), | |
| 1884 RESULT_CODE_KILLED_BAD_MESSAGE)); | |
| 1885 return; | |
| 1886 } | |
| 1887 } | |
| 1888 foreign_fetch_scopes_.insert(foreign_fetch_scopes_.end(), sub_scopes.begin(), | |
| 1889 sub_scopes.end()); | |
| 1890 } | |
| 1891 | |
| 1867 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( | 1892 void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker( |
| 1868 const StatusCallback& callback, | 1893 const StatusCallback& callback, |
| 1869 ServiceWorkerStatusCode status, | 1894 ServiceWorkerStatusCode status, |
| 1870 const scoped_refptr<ServiceWorkerRegistration>& protect) { | 1895 const scoped_refptr<ServiceWorkerRegistration>& protect) { |
| 1871 if (status != SERVICE_WORKER_OK) { | 1896 if (status != SERVICE_WORKER_OK) { |
| 1872 RecordStartWorkerResult(status); | 1897 RecordStartWorkerResult(status); |
| 1873 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED)); | 1898 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED)); |
| 1874 return; | 1899 return; |
| 1875 } | 1900 } |
| 1876 if (is_redundant()) { | 1901 if (is_redundant()) { |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2372 void ServiceWorkerVersion::OnBeginEvent() { | 2397 void ServiceWorkerVersion::OnBeginEvent() { |
| 2373 if (should_exclude_from_uma_ || running_status() != RUNNING || | 2398 if (should_exclude_from_uma_ || running_status() != RUNNING || |
| 2374 idle_time_.is_null()) { | 2399 idle_time_.is_null()) { |
| 2375 return; | 2400 return; |
| 2376 } | 2401 } |
| 2377 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - | 2402 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - |
| 2378 idle_time_); | 2403 idle_time_); |
| 2379 } | 2404 } |
| 2380 | 2405 |
| 2381 } // namespace content | 2406 } // namespace content |
| OLD | NEW |