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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const ServiceWorkerResponse& response); | 66 const ServiceWorkerResponse& response); |
67 void DidHandleNotificationClickEvent( | 67 void DidHandleNotificationClickEvent( |
68 int request_id, | 68 int request_id, |
69 blink::WebServiceWorkerEventResult result); | 69 blink::WebServiceWorkerEventResult result); |
70 void DidHandlePushEvent(int request_id, | 70 void DidHandlePushEvent(int request_id, |
71 blink::WebServiceWorkerEventResult result); | 71 blink::WebServiceWorkerEventResult result); |
72 void DidHandleSyncEvent(int request_id); | 72 void DidHandleSyncEvent(int request_id); |
73 void DidHandleCrossOriginConnectEvent(int request_id, bool accept_connection); | 73 void DidHandleCrossOriginConnectEvent(int request_id, bool accept_connection); |
74 void GetClientDocuments( | 74 void GetClientDocuments( |
75 blink::WebServiceWorkerClientsCallbacks* callbacks); | 75 blink::WebServiceWorkerClientsCallbacks* callbacks); |
| 76 void OpenWindow(const GURL& url, |
| 77 blink::WebServiceWorkerClientCallbacks* callbacks); |
76 void PostMessageToDocument( | 78 void PostMessageToDocument( |
77 int client_id, | 79 int client_id, |
78 const base::string16& message, | 80 const base::string16& message, |
79 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 81 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
80 void PostCrossOriginMessageToClient( | 82 void PostCrossOriginMessageToClient( |
81 const blink::WebCrossOriginServiceWorkerClient& client, | 83 const blink::WebCrossOriginServiceWorkerClient& client, |
82 const base::string16& message, | 84 const base::string16& message, |
83 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 85 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
84 void FocusClient(int client_id, | 86 void FocusClient(int client_id, |
85 blink::WebServiceWorkerClientFocusCallback* callback); | 87 blink::WebServiceWorkerClientFocusCallback* callback); |
86 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 88 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
87 | 89 |
88 // Send a message to the browser. Takes ownership of |message|. | 90 // Send a message to the browser. Takes ownership of |message|. |
89 void Send(IPC::Message* message); | 91 void Send(IPC::Message* message); |
90 | 92 |
91 // Get routing_id for sending message to the ServiceWorkerVersion | 93 // Get routing_id for sending message to the ServiceWorkerVersion |
92 // in the browser process. | 94 // in the browser process. |
93 int GetRoutingID() const; | 95 int GetRoutingID() const; |
94 | 96 |
95 blink::WebServiceWorkerCacheStorage* cache_storage() { | 97 blink::WebServiceWorkerCacheStorage* cache_storage() { |
96 return cache_storage_dispatcher_.get(); | 98 return cache_storage_dispatcher_.get(); |
97 } | 99 } |
98 | 100 |
99 private: | 101 private: |
100 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 102 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
101 ClientsCallbacksMap; | 103 ClientsCallbacksMap; |
| 104 typedef IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer> |
| 105 ClientCallbacksMap; |
102 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> | 106 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> |
103 FocusClientCallbacksMap; | 107 FocusClientCallbacksMap; |
104 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> | 108 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> |
105 SkipWaitingCallbacksMap; | 109 SkipWaitingCallbacksMap; |
106 | 110 |
107 void OnActivateEvent(int request_id); | 111 void OnActivateEvent(int request_id); |
108 void OnInstallEvent(int request_id, int active_version_id); | 112 void OnInstallEvent(int request_id, int active_version_id); |
109 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 113 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
110 void OnSyncEvent(int request_id); | 114 void OnSyncEvent(int request_id); |
111 void OnNotificationClickEvent( | 115 void OnNotificationClickEvent( |
(...skipping 10 matching lines...) Expand all Loading... |
122 void OnPostMessage(const base::string16& message, | 126 void OnPostMessage(const base::string16& message, |
123 const std::vector<int>& sent_message_port_ids, | 127 const std::vector<int>& sent_message_port_ids, |
124 const std::vector<int>& new_routing_ids); | 128 const std::vector<int>& new_routing_ids); |
125 void OnCrossOriginMessageToWorker( | 129 void OnCrossOriginMessageToWorker( |
126 const CrossOriginServiceWorkerClient& client, | 130 const CrossOriginServiceWorkerClient& client, |
127 const base::string16& message, | 131 const base::string16& message, |
128 const std::vector<int>& sent_message_port_ids, | 132 const std::vector<int>& sent_message_port_ids, |
129 const std::vector<int>& new_routing_ids); | 133 const std::vector<int>& new_routing_ids); |
130 void OnDidGetClientDocuments( | 134 void OnDidGetClientDocuments( |
131 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); | 135 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); |
| 136 void OnOpenWindowResponse(int request_id, |
| 137 const ServiceWorkerClientInfo& client); |
| 138 void OnOpenWindowError(int request_id); |
132 void OnFocusClientResponse(int request_id, bool result); | 139 void OnFocusClientResponse(int request_id, bool result); |
133 void OnDidSkipWaiting(int request_id); | 140 void OnDidSkipWaiting(int request_id); |
134 | 141 |
135 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 142 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
136 | 143 |
137 // Not owned; embedded_context_ owns this. | 144 // Not owned; embedded_context_ owns this. |
138 EmbeddedWorkerContextClient* embedded_context_; | 145 EmbeddedWorkerContextClient* embedded_context_; |
139 | 146 |
140 // Not owned; this object is destroyed when proxy_ becomes invalid. | 147 // Not owned; this object is destroyed when proxy_ becomes invalid. |
141 blink::WebServiceWorkerContextProxy* proxy_; | 148 blink::WebServiceWorkerContextProxy* proxy_; |
142 | 149 |
143 // Used for incoming messages from the browser for which an outgoing response | 150 // Used for incoming messages from the browser for which an outgoing response |
144 // back to the browser is expected, the id must be sent back with the | 151 // back to the browser is expected, the id must be sent back with the |
145 // response. | 152 // response. |
146 int current_request_id_; | 153 int current_request_id_; |
147 | 154 |
148 // Pending callbacks for GetClientDocuments(). | 155 // Pending callbacks for GetClientDocuments(). |
149 ClientsCallbacksMap pending_clients_callbacks_; | 156 ClientsCallbacksMap pending_clients_callbacks_; |
150 | 157 |
| 158 // Pending callbacks for OpenWindow(). |
| 159 ClientCallbacksMap pending_client_callbacks_; |
| 160 |
151 // Pending callbacks for FocusClient(). | 161 // Pending callbacks for FocusClient(). |
152 FocusClientCallbacksMap pending_focus_client_callbacks_; | 162 FocusClientCallbacksMap pending_focus_client_callbacks_; |
153 | 163 |
154 // Pending callbacks for SkipWaiting(). | 164 // Pending callbacks for SkipWaiting(). |
155 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; | 165 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
156 | 166 |
157 // Capture timestamps for UMA | 167 // Capture timestamps for UMA |
158 std::map<int, base::TimeTicks> activate_start_timings_; | 168 std::map<int, base::TimeTicks> activate_start_timings_; |
159 std::map<int, base::TimeTicks> fetch_start_timings_; | 169 std::map<int, base::TimeTicks> fetch_start_timings_; |
160 std::map<int, base::TimeTicks> install_start_timings_; | 170 std::map<int, base::TimeTicks> install_start_timings_; |
161 std::map<int, base::TimeTicks> notification_click_start_timings_; | 171 std::map<int, base::TimeTicks> notification_click_start_timings_; |
162 std::map<int, base::TimeTicks> push_start_timings_; | 172 std::map<int, base::TimeTicks> push_start_timings_; |
163 | 173 |
164 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 174 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
165 }; | 175 }; |
166 | 176 |
167 } // namespace content | 177 } // namespace content |
168 | 178 |
169 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 179 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
OLD | NEW |