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