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 23 matching lines...) Expand all Loading... |
34 IPC_MESSAGE_UNHANDLED(handled = false) | 34 IPC_MESSAGE_UNHANDLED(handled = false) |
35 IPC_END_MESSAGE_MAP() | 35 IPC_END_MESSAGE_MAP() |
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( |
| 45 int request_id, |
| 46 const ServiceWorkerFetchResponse& response) { |
| 47 Send(request_id, ServiceWorkerHostMsg_FetchEventFinished(response)); |
| 48 } |
| 49 |
44 void ServiceWorkerScriptContext::Send(int request_id, | 50 void ServiceWorkerScriptContext::Send(int request_id, |
45 const IPC::Message& message) { | 51 const IPC::Message& message) { |
46 embedded_context_->SendMessageToBrowser(request_id, message); | 52 embedded_context_->SendMessageToBrowser(request_id, message); |
47 } | 53 } |
48 | 54 |
49 void ServiceWorkerScriptContext::OnInstallEvent( | 55 void ServiceWorkerScriptContext::OnInstallEvent( |
50 int active_version_embedded_worker_id) { | 56 int active_version_embedded_worker_id) { |
51 proxy_->dispatchInstallEvent(current_request_id_); | 57 proxy_->dispatchInstallEvent(current_request_id_); |
52 } | 58 } |
53 | 59 |
54 void ServiceWorkerScriptContext::OnFetchEvent( | 60 void ServiceWorkerScriptContext::OnFetchEvent( |
55 const ServiceWorkerFetchRequest& request) { | 61 const ServiceWorkerFetchRequest& request) { |
56 NOTIMPLEMENTED(); | 62 // TODO(falken): Dispatch the event to Blink and wait for the response from |
| 63 // respondWith. This is just a dummy response now. |
| 64 DidHandleFetchEvent(current_request_id_, ServiceWorkerFetchResponse( |
| 65 200, "OK", "GET", std::map<std::string, std::string>())); |
57 } | 66 } |
58 | 67 |
59 } // namespace content | 68 } // namespace content |
OLD | NEW |