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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 class WebServiceWorkerContextProxy; | 27 class WebServiceWorkerContextProxy; |
28 } | 28 } |
29 | 29 |
30 namespace IPC { | 30 namespace IPC { |
31 class Message; | 31 class Message; |
32 } | 32 } |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 | 35 |
36 class EmbeddedWorkerContextClient; | 36 class EmbeddedWorkerContextClient; |
| 37 class WebCrossOriginServiceWorkerClientImpl; |
37 | 38 |
38 // TODO(kinuko): This should implement WebServiceWorkerContextClient | 39 // TODO(kinuko): This should implement WebServiceWorkerContextClient |
39 // rather than having EmbeddedWorkerContextClient implement it. | 40 // rather than having EmbeddedWorkerContextClient implement it. |
40 // See the header comment in embedded_worker_context_client.h for the | 41 // See the header comment in embedded_worker_context_client.h for the |
41 // potential EW/SW layering concerns. | 42 // potential EW/SW layering concerns. |
42 class ServiceWorkerScriptContext { | 43 class ServiceWorkerScriptContext { |
43 public: | 44 public: |
44 ServiceWorkerScriptContext( | 45 ServiceWorkerScriptContext( |
45 EmbeddedWorkerContextClient* embedded_context, | 46 EmbeddedWorkerContextClient* embedded_context, |
46 blink::WebServiceWorkerContextProxy* proxy); | 47 blink::WebServiceWorkerContextProxy* proxy); |
47 ~ServiceWorkerScriptContext(); | 48 ~ServiceWorkerScriptContext(); |
48 | 49 |
49 void OnMessageReceived(const IPC::Message& message); | 50 void OnMessageReceived(const IPC::Message& message); |
50 | 51 |
51 void DidHandleActivateEvent(int request_id, | 52 void DidHandleActivateEvent(int request_id, |
52 blink::WebServiceWorkerEventResult); | 53 blink::WebServiceWorkerEventResult); |
53 void DidHandleInstallEvent(int request_id, | 54 void DidHandleInstallEvent(int request_id, |
54 blink::WebServiceWorkerEventResult result); | 55 blink::WebServiceWorkerEventResult result); |
55 void DidHandleFetchEvent(int request_id, | 56 void DidHandleFetchEvent(int request_id, |
56 ServiceWorkerFetchEventResult result, | 57 ServiceWorkerFetchEventResult result, |
57 const ServiceWorkerResponse& response); | 58 const ServiceWorkerResponse& response); |
58 void DidHandleNotificationClickEvent( | 59 void DidHandleNotificationClickEvent( |
59 int request_id, | 60 int request_id, |
60 blink::WebServiceWorkerEventResult result); | 61 blink::WebServiceWorkerEventResult result); |
61 void DidHandlePushEvent(int request_id, | 62 void DidHandlePushEvent(int request_id, |
62 blink::WebServiceWorkerEventResult result); | 63 blink::WebServiceWorkerEventResult result); |
63 void DidHandleSyncEvent(int request_id); | 64 void DidHandleSyncEvent(int request_id); |
| 65 void DidHandleCrossOriginConnectEvent(int request_id, bool allow_connect); |
64 void GetClientDocuments( | 66 void GetClientDocuments( |
65 blink::WebServiceWorkerClientsCallbacks* callbacks); | 67 blink::WebServiceWorkerClientsCallbacks* callbacks); |
66 void PostMessageToDocument( | 68 void PostMessageToDocument( |
67 int client_id, | 69 int client_id, |
68 const base::string16& message, | 70 const base::string16& message, |
69 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 71 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
| 72 void PostCrossOriginMessage( |
| 73 WebCrossOriginServiceWorkerClientImpl* client, |
| 74 const base::string16& message, |
| 75 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
70 | 76 |
71 // Send a message to the browser. Takes ownership of |message|. | 77 // Send a message to the browser. Takes ownership of |message|. |
72 void Send(IPC::Message* message); | 78 void Send(IPC::Message* message); |
73 | 79 |
74 // Get routing_id for sending message to the ServiceWorkerVersion | 80 // Get routing_id for sending message to the ServiceWorkerVersion |
75 // in the browser process. | 81 // in the browser process. |
76 int GetRoutingID() const; | 82 int GetRoutingID() const; |
77 | 83 |
78 blink::WebServiceWorkerCacheStorage* cache_storage() { | 84 blink::WebServiceWorkerCacheStorage* cache_storage() { |
79 return cache_storage_dispatcher_.get(); | 85 return cache_storage_dispatcher_.get(); |
80 } | 86 } |
81 | 87 |
82 private: | 88 private: |
83 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 89 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
84 ClientsCallbacksMap; | 90 ClientsCallbacksMap; |
85 | 91 |
86 | 92 |
87 void OnActivateEvent(int request_id); | 93 void OnActivateEvent(int request_id); |
88 void OnInstallEvent(int request_id, int active_version_id); | 94 void OnInstallEvent(int request_id, int active_version_id); |
89 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 95 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
90 void OnSyncEvent(int request_id); | 96 void OnSyncEvent(int request_id); |
91 void OnNotificationClickEvent(int request_id, | 97 void OnNotificationClickEvent(int request_id, |
92 const std::string& notification_id); | 98 const std::string& notification_id); |
93 void OnPushEvent(int request_id, const std::string& data); | 99 void OnPushEvent(int request_id, const std::string& data); |
94 void OnGeofencingEvent(int request_id, | 100 void OnGeofencingEvent(int request_id, |
95 blink::WebGeofencingEventType event_type, | 101 blink::WebGeofencingEventType event_type, |
96 const std::string& region_id, | 102 const std::string& region_id, |
97 const blink::WebCircularGeofencingRegion& region); | 103 const blink::WebCircularGeofencingRegion& region); |
| 104 void OnCrossOriginConnectEvent(int request_id, |
| 105 const CrossOriginServiceWorkerClient& client); |
| 106 void OnCrossOriginMessageToWorker( |
| 107 const CrossOriginServiceWorkerClient& client, |
| 108 const base::string16& message, |
| 109 const std::vector<int>& sent_message_port_ids, |
| 110 const std::vector<int>& new_routing_ids); |
98 void OnPostMessage(const base::string16& message, | 111 void OnPostMessage(const base::string16& message, |
99 const std::vector<int>& sent_message_port_ids, | 112 const std::vector<int>& sent_message_port_ids, |
100 const std::vector<int>& new_routing_ids); | 113 const std::vector<int>& new_routing_ids); |
101 void OnDidGetClientDocuments( | 114 void OnDidGetClientDocuments( |
102 int request_id, const std::vector<int>& client_ids); | 115 int request_id, const std::vector<int>& client_ids); |
103 | 116 |
104 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 117 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
105 | 118 |
106 // Not owned; embedded_context_ owns this. | 119 // Not owned; embedded_context_ owns this. |
107 EmbeddedWorkerContextClient* embedded_context_; | 120 EmbeddedWorkerContextClient* embedded_context_; |
(...skipping 15 matching lines...) Expand all Loading... |
123 std::map<int, base::TimeTicks> install_start_timings_; | 136 std::map<int, base::TimeTicks> install_start_timings_; |
124 std::map<int, base::TimeTicks> notification_click_start_timings_; | 137 std::map<int, base::TimeTicks> notification_click_start_timings_; |
125 std::map<int, base::TimeTicks> push_start_timings_; | 138 std::map<int, base::TimeTicks> push_start_timings_; |
126 | 139 |
127 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 140 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
128 }; | 141 }; |
129 | 142 |
130 } // namespace content | 143 } // namespace content |
131 | 144 |
132 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 145 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
OLD | NEW |