| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/service_worker/service_worker_script_context.h" | 5 #include "content/renderer/service_worker/service_worker_script_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/service_worker/service_worker_messages.h" | 8 #include "content/common/service_worker/service_worker_messages.h" |
| 9 #include "content/renderer/service_worker/embedded_worker_context_client.h" | 9 #include "content/renderer/service_worker/embedded_worker_context_client.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 DCHECK(handled); | 36 DCHECK(handled); |
| 37 current_request_id_ = kInvalidRequestId; | 37 current_request_id_ = kInvalidRequestId; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void ServiceWorkerScriptContext::DidHandleInstallEvent(int request_id) { | 40 void ServiceWorkerScriptContext::DidHandleInstallEvent(int request_id) { |
| 41 Send(request_id, ServiceWorkerHostMsg_InstallEventFinished()); | 41 Send(request_id, ServiceWorkerHostMsg_InstallEventFinished()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void ServiceWorkerScriptContext::DidHandleFetchEvent( | 44 void ServiceWorkerScriptContext::DidHandleFetchEvent( |
| 45 int request_id, | 45 int request_id, |
| 46 const ServiceWorkerFetchResponse& response) { | 46 ServiceWorkerFetchEventResult result, |
| 47 Send(request_id, ServiceWorkerHostMsg_FetchEventFinished(response)); | 47 const ServiceWorkerResponse& response) { |
| 48 Send(request_id, ServiceWorkerHostMsg_FetchEventFinished(result, response)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void ServiceWorkerScriptContext::Send(int request_id, | 51 void ServiceWorkerScriptContext::Send(int request_id, |
| 51 const IPC::Message& message) { | 52 const IPC::Message& message) { |
| 52 embedded_context_->SendMessageToBrowser(request_id, message); | 53 embedded_context_->SendMessageToBrowser(request_id, message); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void ServiceWorkerScriptContext::OnInstallEvent( | 56 void ServiceWorkerScriptContext::OnInstallEvent( |
| 56 int active_version_embedded_worker_id) { | 57 int active_version_embedded_worker_id) { |
| 57 proxy_->dispatchInstallEvent(current_request_id_); | 58 proxy_->dispatchInstallEvent(current_request_id_); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void ServiceWorkerScriptContext::OnFetchEvent( | 61 void ServiceWorkerScriptContext::OnFetchEvent( |
| 61 const ServiceWorkerFetchRequest& request) { | 62 const ServiceWorkerFetchRequest& request) { |
| 62 // TODO(falken): Dispatch the event to Blink and wait for the response from | 63 // TODO(falken): Pass in the request. |
| 63 // respondWith. This is just a dummy response now. | 64 proxy_->dispatchFetchEvent(current_request_id_); |
| 64 DidHandleFetchEvent(current_request_id_, ServiceWorkerFetchResponse( | |
| 65 200, "OK", "GET", std::map<std::string, std::string>())); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 } // namespace content | 67 } // namespace content |
| OLD | NEW |