| 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 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 #include "content/common/service_worker/service_worker_types.h" |
| 11 |
| 10 namespace blink { | 12 namespace blink { |
| 11 class WebServiceWorkerContextProxy; | 13 class WebServiceWorkerContextProxy; |
| 12 } | 14 } |
| 13 | 15 |
| 14 namespace IPC { | 16 namespace IPC { |
| 15 class Message; | 17 class Message; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 | 21 |
| 20 class EmbeddedWorkerContextClient; | 22 class EmbeddedWorkerContextClient; |
| 21 struct ServiceWorkerFetchRequest; | |
| 22 struct ServiceWorkerFetchResponse; | |
| 23 | 23 |
| 24 // TODO(kinuko): This should implement WebServiceWorkerContextClient | 24 // TODO(kinuko): This should implement WebServiceWorkerContextClient |
| 25 // rather than having EmbeddedWorkerContextClient implement it. | 25 // rather than having EmbeddedWorkerContextClient implement it. |
| 26 // See the header comment in embedded_worker_context_client.h for the | 26 // See the header comment in embedded_worker_context_client.h for the |
| 27 // potential EW/SW layering concerns. | 27 // potential EW/SW layering concerns. |
| 28 class ServiceWorkerScriptContext { | 28 class ServiceWorkerScriptContext { |
| 29 public: | 29 public: |
| 30 ServiceWorkerScriptContext( | 30 ServiceWorkerScriptContext( |
| 31 EmbeddedWorkerContextClient* embedded_context, | 31 EmbeddedWorkerContextClient* embedded_context, |
| 32 blink::WebServiceWorkerContextProxy* proxy); | 32 blink::WebServiceWorkerContextProxy* proxy); |
| 33 ~ServiceWorkerScriptContext(); | 33 ~ServiceWorkerScriptContext(); |
| 34 | 34 |
| 35 void OnMessageReceived(int request_id, const IPC::Message& message); | 35 void OnMessageReceived(int request_id, const IPC::Message& message); |
| 36 | 36 |
| 37 void DidHandleInstallEvent(int request_id); | 37 void DidHandleInstallEvent(int request_id); |
| 38 void DidHandleFetchEvent(int request_id, | 38 void DidHandleFetchEvent(int request_id, |
| 39 const ServiceWorkerFetchResponse& response); | 39 ServiceWorkerFetchEventResult result, |
| 40 const ServiceWorkerResponse& response); |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 // Send message back to the browser. | 43 // Send message back to the browser. |
| 43 void Send(int request_id, const IPC::Message& message); | 44 void Send(int request_id, const IPC::Message& message); |
| 44 | 45 |
| 45 void OnInstallEvent(int active_version_embedded_worker_id); | 46 void OnInstallEvent(int active_version_embedded_worker_id); |
| 46 void OnFetchEvent(const ServiceWorkerFetchRequest& request); | 47 void OnFetchEvent(const ServiceWorkerFetchRequest& request); |
| 47 | 48 |
| 48 // Not owned; embedded_context_ owns this. | 49 // Not owned; embedded_context_ owns this. |
| 49 EmbeddedWorkerContextClient* embedded_context_; | 50 EmbeddedWorkerContextClient* embedded_context_; |
| 50 | 51 |
| 51 // Not owned; this object is destroyed when proxy_ becomes invalid. | 52 // Not owned; this object is destroyed when proxy_ becomes invalid. |
| 52 blink::WebServiceWorkerContextProxy* proxy_; | 53 blink::WebServiceWorkerContextProxy* proxy_; |
| 53 | 54 |
| 54 // Used by message handlers. | 55 // Used by message handlers. |
| 55 int current_request_id_; | 56 int current_request_id_; |
| 56 | 57 |
| 57 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 58 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 } // namespace content | 61 } // namespace content |
| 61 | 62 |
| 62 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 63 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| OLD | NEW |