| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "content/child/webmessageportchannel_impl.h" | 15 #include "content/child/webmessageportchannel_impl.h" |
| 15 #include "content/common/service_worker/service_worker_types.h" | 16 #include "content/common/service_worker/service_worker_types.h" |
| 17 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche
r.h" |
| 16 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 18 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 17 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" | 19 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" |
| 18 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 20 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
| 19 | 21 |
| 20 namespace blink { | 22 namespace blink { |
| 21 class WebServiceWorkerContextProxy; | 23 class WebServiceWorkerContextProxy; |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace IPC { | 26 namespace IPC { |
| 25 class Message; | 27 class Message; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 ServiceWorkerFetchEventResult result, | 52 ServiceWorkerFetchEventResult result, |
| 51 const ServiceWorkerResponse& response); | 53 const ServiceWorkerResponse& response); |
| 52 void DidHandleSyncEvent(int request_id); | 54 void DidHandleSyncEvent(int request_id); |
| 53 void GetClientDocuments( | 55 void GetClientDocuments( |
| 54 blink::WebServiceWorkerClientsCallbacks* callbacks); | 56 blink::WebServiceWorkerClientsCallbacks* callbacks); |
| 55 void PostMessageToDocument( | 57 void PostMessageToDocument( |
| 56 int client_id, | 58 int client_id, |
| 57 const base::string16& message, | 59 const base::string16& message, |
| 58 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 60 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
| 59 | 61 |
| 62 // Send a message to the browser. Takes ownership of |message|. |
| 63 void Send(IPC::Message* message); |
| 64 |
| 65 // Get routing_id for sending message to the ServiceWorkerVersion |
| 66 // in the browser process. |
| 67 int GetRoutingID() const; |
| 68 |
| 69 blink::WebServiceWorkerCacheStorage* cache_storage() { |
| 70 return cache_storage_dispatcher_.get(); |
| 71 } |
| 72 |
| 60 private: | 73 private: |
| 61 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 74 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
| 62 ClientsCallbacksMap; | 75 ClientsCallbacksMap; |
| 63 | 76 |
| 64 // Send a message to the browser. | |
| 65 void Send(IPC::Message* message); | |
| 66 | 77 |
| 67 void OnActivateEvent(int request_id); | 78 void OnActivateEvent(int request_id); |
| 68 void OnInstallEvent(int request_id, int active_version_id); | 79 void OnInstallEvent(int request_id, int active_version_id); |
| 69 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 80 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
| 70 void OnSyncEvent(int request_id); | 81 void OnSyncEvent(int request_id); |
| 71 void OnPushEvent(int request_id, const std::string& data); | 82 void OnPushEvent(int request_id, const std::string& data); |
| 72 void OnPostMessage(const base::string16& message, | 83 void OnPostMessage(const base::string16& message, |
| 73 const std::vector<int>& sent_message_port_ids, | 84 const std::vector<int>& sent_message_port_ids, |
| 74 const std::vector<int>& new_routing_ids); | 85 const std::vector<int>& new_routing_ids); |
| 75 void OnDidGetClientDocuments( | 86 void OnDidGetClientDocuments( |
| 76 int request_id, const std::vector<int>& client_ids); | 87 int request_id, const std::vector<int>& client_ids); |
| 77 | 88 |
| 78 // Get routing_id for sending message to the ServiceWorkerVersion | 89 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
| 79 // in the browser process. | |
| 80 int GetRoutingID() const; | |
| 81 | 90 |
| 82 // Not owned; embedded_context_ owns this. | 91 // Not owned; embedded_context_ owns this. |
| 83 EmbeddedWorkerContextClient* embedded_context_; | 92 EmbeddedWorkerContextClient* embedded_context_; |
| 84 | 93 |
| 85 // Not owned; this object is destroyed when proxy_ becomes invalid. | 94 // Not owned; this object is destroyed when proxy_ becomes invalid. |
| 86 blink::WebServiceWorkerContextProxy* proxy_; | 95 blink::WebServiceWorkerContextProxy* proxy_; |
| 87 | 96 |
| 88 // Used for incoming messages from the browser for which an outgoing response | 97 // Used for incoming messages from the browser for which an outgoing response |
| 89 // back to the browser is expected, the id must be sent back with the | 98 // back to the browser is expected, the id must be sent back with the |
| 90 // response. | 99 // response. |
| 91 int current_request_id_; | 100 int current_request_id_; |
| 92 | 101 |
| 93 // Pending callbacks for GetClientDocuments(). | 102 // Pending callbacks for GetClientDocuments(). |
| 94 ClientsCallbacksMap pending_clients_callbacks_; | 103 ClientsCallbacksMap pending_clients_callbacks_; |
| 95 | 104 |
| 96 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 105 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
| 97 }; | 106 }; |
| 98 | 107 |
| 99 } // namespace content | 108 } // namespace content |
| 100 | 109 |
| 101 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 110 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| OLD | NEW |