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 <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 // running status can be STARTING here. | 1057 // running status can be STARTING here. |
1058 if (running_status() != EmbeddedWorkerStatus::STARTING && | 1058 if (running_status() != EmbeddedWorkerStatus::STARTING && |
1059 running_status() != EmbeddedWorkerStatus::RUNNING) { | 1059 running_status() != EmbeddedWorkerStatus::RUNNING) { |
1060 return; | 1060 return; |
1061 } | 1061 } |
1062 | 1062 |
1063 embedded_worker_->SendMessage( | 1063 embedded_worker_->SendMessage( |
1064 ServiceWorkerMsg_DidGetClients(request_id, *clients)); | 1064 ServiceWorkerMsg_DidGetClients(request_id, *clients)); |
1065 } | 1065 } |
1066 | 1066 |
| 1067 void ServiceWorkerVersion::OnSimpleEventFinished( |
| 1068 int request_id, |
| 1069 ServiceWorkerStatusCode status, |
| 1070 base::Time dispatch_event_time) { |
| 1071 // Copy error callback before calling FinishRequest. |
| 1072 PendingRequest* request = pending_requests_.Lookup(request_id); |
| 1073 DCHECK(request) << "Invalid request id"; |
| 1074 StatusCallback callback = request->error_callback; |
| 1075 |
| 1076 FinishRequest(request_id, status == SERVICE_WORKER_OK, dispatch_event_time); |
| 1077 |
| 1078 callback.Run(status); |
| 1079 } |
| 1080 |
1067 void ServiceWorkerVersion::OnSimpleEventResponse( | 1081 void ServiceWorkerVersion::OnSimpleEventResponse( |
1068 int request_id, | 1082 int request_id, |
1069 blink::WebServiceWorkerEventResult result, | 1083 blink::WebServiceWorkerEventResult result, |
1070 base::Time dispatch_event_time) { | 1084 base::Time dispatch_event_time) { |
1071 // Copy error callback before calling FinishRequest. | |
1072 PendingRequest* request = pending_requests_.Lookup(request_id); | |
1073 DCHECK(request) << "Invalid request id"; | |
1074 StatusCallback callback = request->error_callback; | |
1075 | |
1076 FinishRequest(request_id, | |
1077 result == blink::WebServiceWorkerEventResultCompleted, | |
1078 dispatch_event_time); | |
1079 | |
1080 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; | 1085 ServiceWorkerStatusCode status = SERVICE_WORKER_OK; |
1081 if (result == blink::WebServiceWorkerEventResultRejected) | 1086 if (result == blink::WebServiceWorkerEventResultRejected) |
1082 status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; | 1087 status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; |
1083 callback.Run(status); | 1088 OnSimpleEventFinished(request_id, status, dispatch_event_time); |
1084 } | 1089 } |
1085 | 1090 |
1086 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { | 1091 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { |
1087 // Just abort if we are shutting down. | 1092 // Just abort if we are shutting down. |
1088 if (!context_) | 1093 if (!context_) |
1089 return; | 1094 return; |
1090 | 1095 |
1091 if (!url.is_valid()) { | 1096 if (!url.is_valid()) { |
1092 DVLOG(1) << "Received unexpected invalid URL from renderer process."; | 1097 DVLOG(1) << "Received unexpected invalid URL from renderer process."; |
1093 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 1098 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 | 1864 |
1860 void ServiceWorkerVersion::CleanUpExternalRequest( | 1865 void ServiceWorkerVersion::CleanUpExternalRequest( |
1861 const std::string& request_uuid, | 1866 const std::string& request_uuid, |
1862 ServiceWorkerStatusCode status) { | 1867 ServiceWorkerStatusCode status) { |
1863 if (status == SERVICE_WORKER_OK) | 1868 if (status == SERVICE_WORKER_OK) |
1864 return; | 1869 return; |
1865 external_request_uuid_to_request_id_.erase(request_uuid); | 1870 external_request_uuid_to_request_id_.erase(request_uuid); |
1866 } | 1871 } |
1867 | 1872 |
1868 } // namespace content | 1873 } // namespace content |
OLD | NEW |