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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "content/child/webmessageportchannel_impl.h" | 17 #include "content/child/webmessageportchannel_impl.h" |
18 #include "content/common/service_worker/service_worker_types.h" | 18 #include "content/common/service_worker/service_worker_types.h" |
19 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche
r.h" | 19 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche
r.h" |
20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" | 20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" |
21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientFocusCallback
.h" | 22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientFocusCallback
.h" |
23 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" | 23 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" |
24 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 24 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
| 25 #include "third_party/WebKit/public/platform/WebServiceWorkerSkipWaitingCallback
s.h" |
25 | 26 |
26 namespace blink { | 27 namespace blink { |
27 struct WebCircularGeofencingRegion; | 28 struct WebCircularGeofencingRegion; |
28 class WebServiceWorkerContextProxy; | 29 class WebServiceWorkerContextProxy; |
29 } | 30 } |
30 | 31 |
31 namespace IPC { | 32 namespace IPC { |
32 class Message; | 33 class Message; |
33 } | 34 } |
34 | 35 |
(...skipping 29 matching lines...) Expand all Loading... |
64 blink::WebServiceWorkerEventResult result); | 65 blink::WebServiceWorkerEventResult result); |
65 void DidHandleSyncEvent(int request_id); | 66 void DidHandleSyncEvent(int request_id); |
66 void GetClientDocuments( | 67 void GetClientDocuments( |
67 blink::WebServiceWorkerClientsCallbacks* callbacks); | 68 blink::WebServiceWorkerClientsCallbacks* callbacks); |
68 void PostMessageToDocument( | 69 void PostMessageToDocument( |
69 int client_id, | 70 int client_id, |
70 const base::string16& message, | 71 const base::string16& message, |
71 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 72 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
72 void FocusClient(int client_id, | 73 void FocusClient(int client_id, |
73 blink::WebServiceWorkerClientFocusCallback* callback); | 74 blink::WebServiceWorkerClientFocusCallback* callback); |
| 75 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
74 | 76 |
75 // Send a message to the browser. Takes ownership of |message|. | 77 // Send a message to the browser. Takes ownership of |message|. |
76 void Send(IPC::Message* message); | 78 void Send(IPC::Message* message); |
77 | 79 |
78 // Get routing_id for sending message to the ServiceWorkerVersion | 80 // Get routing_id for sending message to the ServiceWorkerVersion |
79 // in the browser process. | 81 // in the browser process. |
80 int GetRoutingID() const; | 82 int GetRoutingID() const; |
81 | 83 |
82 blink::WebServiceWorkerCacheStorage* cache_storage() { | 84 blink::WebServiceWorkerCacheStorage* cache_storage() { |
83 return cache_storage_dispatcher_.get(); | 85 return cache_storage_dispatcher_.get(); |
84 } | 86 } |
85 | 87 |
86 private: | 88 private: |
87 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 89 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
88 ClientsCallbacksMap; | 90 ClientsCallbacksMap; |
89 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> | 91 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> |
90 FocusClientCallbacksMap; | 92 FocusClientCallbacksMap; |
| 93 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> |
| 94 SkipWaitingCallbacksMap; |
91 | 95 |
92 void OnActivateEvent(int request_id); | 96 void OnActivateEvent(int request_id); |
93 void OnInstallEvent(int request_id, int active_version_id); | 97 void OnInstallEvent(int request_id, int active_version_id); |
94 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 98 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
95 void OnSyncEvent(int request_id); | 99 void OnSyncEvent(int request_id); |
96 void OnNotificationClickEvent( | 100 void OnNotificationClickEvent( |
97 int request_id, | 101 int request_id, |
98 const std::string& notification_id, | 102 const std::string& notification_id, |
99 const ShowDesktopNotificationHostMsgParams& notification_data); | 103 const ShowDesktopNotificationHostMsgParams& notification_data); |
100 void OnPushEvent(int request_id, const std::string& data); | 104 void OnPushEvent(int request_id, const std::string& data); |
101 void OnGeofencingEvent(int request_id, | 105 void OnGeofencingEvent(int request_id, |
102 blink::WebGeofencingEventType event_type, | 106 blink::WebGeofencingEventType event_type, |
103 const std::string& region_id, | 107 const std::string& region_id, |
104 const blink::WebCircularGeofencingRegion& region); | 108 const blink::WebCircularGeofencingRegion& region); |
105 void OnPostMessage(const base::string16& message, | 109 void OnPostMessage(const base::string16& message, |
106 const std::vector<int>& sent_message_port_ids, | 110 const std::vector<int>& sent_message_port_ids, |
107 const std::vector<int>& new_routing_ids); | 111 const std::vector<int>& new_routing_ids); |
108 void OnDidGetClientDocuments( | 112 void OnDidGetClientDocuments( |
109 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); | 113 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); |
110 void OnFocusClientResponse(int request_id, bool result); | 114 void OnFocusClientResponse(int request_id, bool result); |
| 115 void OnDidSkipWaiting(int request_id); |
111 | 116 |
112 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 117 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
113 | 118 |
114 // Not owned; embedded_context_ owns this. | 119 // Not owned; embedded_context_ owns this. |
115 EmbeddedWorkerContextClient* embedded_context_; | 120 EmbeddedWorkerContextClient* embedded_context_; |
116 | 121 |
117 // Not owned; this object is destroyed when proxy_ becomes invalid. | 122 // Not owned; this object is destroyed when proxy_ becomes invalid. |
118 blink::WebServiceWorkerContextProxy* proxy_; | 123 blink::WebServiceWorkerContextProxy* proxy_; |
119 | 124 |
120 // Used for incoming messages from the browser for which an outgoing response | 125 // Used for incoming messages from the browser for which an outgoing response |
121 // back to the browser is expected, the id must be sent back with the | 126 // back to the browser is expected, the id must be sent back with the |
122 // response. | 127 // response. |
123 int current_request_id_; | 128 int current_request_id_; |
124 | 129 |
125 // Pending callbacks for GetClientDocuments(). | 130 // Pending callbacks for GetClientDocuments(). |
126 ClientsCallbacksMap pending_clients_callbacks_; | 131 ClientsCallbacksMap pending_clients_callbacks_; |
127 | 132 |
128 // Pending callbacks for FocusClient(). | 133 // Pending callbacks for FocusClient(). |
129 FocusClientCallbacksMap pending_focus_client_callbacks_; | 134 FocusClientCallbacksMap pending_focus_client_callbacks_; |
130 | 135 |
| 136 // Pending callbacks for SkipWaiting(). |
| 137 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
| 138 |
131 // Capture timestamps for UMA | 139 // Capture timestamps for UMA |
132 std::map<int, base::TimeTicks> activate_start_timings_; | 140 std::map<int, base::TimeTicks> activate_start_timings_; |
133 std::map<int, base::TimeTicks> fetch_start_timings_; | 141 std::map<int, base::TimeTicks> fetch_start_timings_; |
134 std::map<int, base::TimeTicks> install_start_timings_; | 142 std::map<int, base::TimeTicks> install_start_timings_; |
135 std::map<int, base::TimeTicks> notification_click_start_timings_; | 143 std::map<int, base::TimeTicks> notification_click_start_timings_; |
136 std::map<int, base::TimeTicks> push_start_timings_; | 144 std::map<int, base::TimeTicks> push_start_timings_; |
137 | 145 |
138 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 146 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
139 }; | 147 }; |
140 | 148 |
141 } // namespace content | 149 } // namespace content |
142 | 150 |
143 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 151 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
OLD | NEW |