Chromium Code Reviews| 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" |
| 11 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" | 11 #include "third_party/WebKit/public/web/WebServiceWorkerContextProxy.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 ServiceWorkerScriptContext::ServiceWorkerScriptContext( | 15 ServiceWorkerScriptContext::ServiceWorkerScriptContext( |
| 16 EmbeddedWorkerContextClient* embedded_context, | 16 EmbeddedWorkerContextClient* embedded_context, |
| 17 blink::WebServiceWorkerContextProxy* proxy) | 17 blink::WebServiceWorkerContextProxy* proxy) |
| 18 : embedded_context_(embedded_context), | 18 : embedded_context_(embedded_context), |
| 19 proxy_(proxy) { | 19 proxy_(proxy), |
| 20 current_request_id_(-1) { | |
|
jsbell
2014/02/04 23:29:03
Ditto, -1 as magic number. Can you use an enum/con
| |
| 20 } | 21 } |
| 21 | 22 |
| 22 ServiceWorkerScriptContext::~ServiceWorkerScriptContext() {} | 23 ServiceWorkerScriptContext::~ServiceWorkerScriptContext() {} |
| 23 | 24 |
| 24 void ServiceWorkerScriptContext::OnMessageReceived( | 25 void ServiceWorkerScriptContext::OnMessageReceived( |
| 26 int request_id, | |
| 25 const IPC::Message& message) { | 27 const IPC::Message& message) { |
| 28 DCHECK_EQ(-1, current_request_id_); | |
| 29 current_request_id_ = request_id; | |
| 26 bool handled = true; | 30 bool handled = true; |
| 27 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerScriptContext, message) | 31 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerScriptContext, message) |
| 28 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent) | 32 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent) |
| 29 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
| 30 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
| 31 DCHECK(handled); | 35 DCHECK(handled); |
| 36 current_request_id_ = -1; | |
| 32 } | 37 } |
| 33 | 38 |
| 34 void ServiceWorkerScriptContext::Send(const IPC::Message& message) { | 39 void ServiceWorkerScriptContext::Send(int request_id, |
| 35 embedded_context_->SendMessageToBrowser(message); | 40 const IPC::Message& message) { |
| 41 embedded_context_->SendMessageToBrowser(request_id, message); | |
| 36 } | 42 } |
| 37 | 43 |
| 38 void ServiceWorkerScriptContext::OnFetchEvent( | 44 void ServiceWorkerScriptContext::OnFetchEvent( |
| 39 const ServiceWorkerFetchRequest& request) { | 45 const ServiceWorkerFetchRequest& request) { |
| 40 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
| 41 } | 47 } |
| 42 | 48 |
| 43 } // namespace content | 49 } // namespace content |
| OLD | NEW |