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/WebServiceWorkerClientsInfo.h" | 22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" |
23 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 23 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
| 24 #include "third_party/WebKit/public/platform/WebServiceWorkerSkipWaitingCallback
s.h" |
24 | 25 |
25 namespace blink { | 26 namespace blink { |
26 struct WebCircularGeofencingRegion; | 27 struct WebCircularGeofencingRegion; |
27 class WebServiceWorkerContextProxy; | 28 class WebServiceWorkerContextProxy; |
28 } | 29 } |
29 | 30 |
30 namespace IPC { | 31 namespace IPC { |
31 class Message; | 32 class Message; |
32 } | 33 } |
33 | 34 |
(...skipping 23 matching lines...) Expand all Loading... |
57 const ServiceWorkerResponse& response); | 58 const ServiceWorkerResponse& response); |
58 void DidHandlePushEvent(int request_id, | 59 void DidHandlePushEvent(int request_id, |
59 blink::WebServiceWorkerEventResult result); | 60 blink::WebServiceWorkerEventResult result); |
60 void DidHandleSyncEvent(int request_id); | 61 void DidHandleSyncEvent(int request_id); |
61 void GetClientDocuments( | 62 void GetClientDocuments( |
62 blink::WebServiceWorkerClientsCallbacks* callbacks); | 63 blink::WebServiceWorkerClientsCallbacks* callbacks); |
63 void PostMessageToDocument( | 64 void PostMessageToDocument( |
64 int client_id, | 65 int client_id, |
65 const base::string16& message, | 66 const base::string16& message, |
66 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 67 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
| 68 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
67 | 69 |
68 // Send a message to the browser. Takes ownership of |message|. | 70 // Send a message to the browser. Takes ownership of |message|. |
69 void Send(IPC::Message* message); | 71 void Send(IPC::Message* message); |
70 | 72 |
71 // Get routing_id for sending message to the ServiceWorkerVersion | 73 // Get routing_id for sending message to the ServiceWorkerVersion |
72 // in the browser process. | 74 // in the browser process. |
73 int GetRoutingID() const; | 75 int GetRoutingID() const; |
74 | 76 |
75 blink::WebServiceWorkerCacheStorage* cache_storage() { | 77 blink::WebServiceWorkerCacheStorage* cache_storage() { |
76 return cache_storage_dispatcher_.get(); | 78 return cache_storage_dispatcher_.get(); |
77 } | 79 } |
78 | 80 |
79 private: | 81 private: |
80 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 82 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
81 ClientsCallbacksMap; | 83 ClientsCallbacksMap; |
82 | 84 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> |
| 85 SkipWaitingCallbacksMap; |
83 | 86 |
84 void OnActivateEvent(int request_id); | 87 void OnActivateEvent(int request_id); |
85 void OnInstallEvent(int request_id, int active_version_id); | 88 void OnInstallEvent(int request_id, int active_version_id); |
86 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 89 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
87 void OnSyncEvent(int request_id); | 90 void OnSyncEvent(int request_id); |
88 void OnPushEvent(int request_id, const std::string& data); | 91 void OnPushEvent(int request_id, const std::string& data); |
89 void OnGeofencingEvent(int request_id, | 92 void OnGeofencingEvent(int request_id, |
90 blink::WebGeofencingEventType event_type, | 93 blink::WebGeofencingEventType event_type, |
91 const std::string& region_id, | 94 const std::string& region_id, |
92 const blink::WebCircularGeofencingRegion& region); | 95 const blink::WebCircularGeofencingRegion& region); |
93 void OnPostMessage(const base::string16& message, | 96 void OnPostMessage(const base::string16& message, |
94 const std::vector<int>& sent_message_port_ids, | 97 const std::vector<int>& sent_message_port_ids, |
95 const std::vector<int>& new_routing_ids); | 98 const std::vector<int>& new_routing_ids); |
96 void OnDidGetClientDocuments( | 99 void OnDidGetClientDocuments( |
97 int request_id, const std::vector<int>& client_ids); | 100 int request_id, const std::vector<int>& client_ids); |
| 101 void OnDidSkipWaiting(int request_id); |
98 | 102 |
99 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 103 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
100 | 104 |
101 // Not owned; embedded_context_ owns this. | 105 // Not owned; embedded_context_ owns this. |
102 EmbeddedWorkerContextClient* embedded_context_; | 106 EmbeddedWorkerContextClient* embedded_context_; |
103 | 107 |
104 // Not owned; this object is destroyed when proxy_ becomes invalid. | 108 // Not owned; this object is destroyed when proxy_ becomes invalid. |
105 blink::WebServiceWorkerContextProxy* proxy_; | 109 blink::WebServiceWorkerContextProxy* proxy_; |
106 | 110 |
107 // Used for incoming messages from the browser for which an outgoing response | 111 // Used for incoming messages from the browser for which an outgoing response |
108 // back to the browser is expected, the id must be sent back with the | 112 // back to the browser is expected, the id must be sent back with the |
109 // response. | 113 // response. |
110 int current_request_id_; | 114 int current_request_id_; |
111 | 115 |
112 // Pending callbacks for GetClientDocuments(). | 116 // Pending callbacks for GetClientDocuments(). |
113 ClientsCallbacksMap pending_clients_callbacks_; | 117 ClientsCallbacksMap pending_clients_callbacks_; |
114 | 118 |
| 119 // Pending callbacks for SkipWaiting(). |
| 120 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
| 121 |
115 // Capture timestamps for UMA | 122 // Capture timestamps for UMA |
116 std::map<int, base::TimeTicks> activate_start_timings_; | 123 std::map<int, base::TimeTicks> activate_start_timings_; |
117 std::map<int, base::TimeTicks> fetch_start_timings_; | 124 std::map<int, base::TimeTicks> fetch_start_timings_; |
118 std::map<int, base::TimeTicks> install_start_timings_; | 125 std::map<int, base::TimeTicks> install_start_timings_; |
119 std::map<int, base::TimeTicks> push_start_timings_; | 126 std::map<int, base::TimeTicks> push_start_timings_; |
120 | 127 |
121 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 128 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
122 }; | 129 }; |
123 | 130 |
124 } // namespace content | 131 } // namespace content |
125 | 132 |
126 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 133 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
OLD | NEW |