| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 | 12 |
| 13 #include "content/common/service_worker/service_worker_types.h" | 13 #include "content/common/service_worker/service_worker_types.h" |
| 14 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 class WebServiceWorkerContextProxy; | 17 class WebServiceWorkerContextProxy; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace IPC { | 20 namespace IPC { |
| 20 class Message; | 21 class Message; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 class EmbeddedWorkerContextClient; | 26 class EmbeddedWorkerContextClient; |
| 26 | 27 |
| 27 // TODO(kinuko): This should implement WebServiceWorkerContextClient | 28 // TODO(kinuko): This should implement WebServiceWorkerContextClient |
| 28 // rather than having EmbeddedWorkerContextClient implement it. | 29 // rather than having EmbeddedWorkerContextClient implement it. |
| 29 // See the header comment in embedded_worker_context_client.h for the | 30 // See the header comment in embedded_worker_context_client.h for the |
| 30 // potential EW/SW layering concerns. | 31 // potential EW/SW layering concerns. |
| 31 class ServiceWorkerScriptContext { | 32 class ServiceWorkerScriptContext { |
| 32 public: | 33 public: |
| 33 ServiceWorkerScriptContext( | 34 ServiceWorkerScriptContext( |
| 34 EmbeddedWorkerContextClient* embedded_context, | 35 EmbeddedWorkerContextClient* embedded_context, |
| 35 blink::WebServiceWorkerContextProxy* proxy); | 36 blink::WebServiceWorkerContextProxy* proxy); |
| 36 ~ServiceWorkerScriptContext(); | 37 ~ServiceWorkerScriptContext(); |
| 37 | 38 |
| 38 void OnMessageReceived(int request_id, const IPC::Message& message); | 39 void OnMessageReceived(int request_id, const IPC::Message& message); |
| 39 | 40 |
| 40 void DidHandleInstallEvent(int request_id); | 41 void DidHandleInstallEvent(int request_id, |
| 42 blink::WebServiceWorkerEventResult result); |
| 41 void DidHandleFetchEvent(int request_id, | 43 void DidHandleFetchEvent(int request_id, |
| 42 ServiceWorkerFetchEventResult result, | 44 ServiceWorkerFetchEventResult result, |
| 43 const ServiceWorkerResponse& response); | 45 const ServiceWorkerResponse& response); |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 // Send message back to the browser. | 48 // Send message back to the browser. |
| 47 void Send(int request_id, const IPC::Message& message); | 49 void Send(int request_id, const IPC::Message& message); |
| 48 | 50 |
| 49 void OnInstallEvent(int active_version_embedded_worker_id); | 51 void OnInstallEvent(int active_version_id); |
| 50 void OnFetchEvent(const ServiceWorkerFetchRequest& request); | 52 void OnFetchEvent(const ServiceWorkerFetchRequest& request); |
| 51 void OnPostMessage(const base::string16& message, | 53 void OnPostMessage(const base::string16& message, |
| 52 const std::vector<int>& sent_message_port_ids, | 54 const std::vector<int>& sent_message_port_ids, |
| 53 const std::vector<int>& new_routing_ids); | 55 const std::vector<int>& new_routing_ids); |
| 54 | 56 |
| 55 // Not owned; embedded_context_ owns this. | 57 // Not owned; embedded_context_ owns this. |
| 56 EmbeddedWorkerContextClient* embedded_context_; | 58 EmbeddedWorkerContextClient* embedded_context_; |
| 57 | 59 |
| 58 // Not owned; this object is destroyed when proxy_ becomes invalid. | 60 // Not owned; this object is destroyed when proxy_ becomes invalid. |
| 59 blink::WebServiceWorkerContextProxy* proxy_; | 61 blink::WebServiceWorkerContextProxy* proxy_; |
| 60 | 62 |
| 61 // Used for incoming messages from the browser for which an outgoing response | 63 // Used for incoming messages from the browser for which an outgoing response |
| 62 // back to the browser is expected, the id must be sent back with the | 64 // back to the browser is expected, the id must be sent back with the |
| 63 // response. | 65 // response. |
| 64 int current_request_id_; | 66 int current_request_id_; |
| 65 | 67 |
| 66 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 68 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace content | 71 } // namespace content |
| 70 | 72 |
| 71 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 73 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| OLD | NEW |