Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.h

Issue 717353004: ServiceWorker: Add support for .skipWaiting and controllerchange event(2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing '!' Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/WebCallback.h"
20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" 21 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" 22 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" 23 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h"
23 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" 24 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.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
(...skipping 25 matching lines...) Expand all
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 DidHandleSyncEvent(int request_id); 59 void DidHandleSyncEvent(int request_id);
59 void GetClientDocuments( 60 void GetClientDocuments(
60 blink::WebServiceWorkerClientsCallbacks* callbacks); 61 blink::WebServiceWorkerClientsCallbacks* callbacks);
61 void PostMessageToDocument( 62 void PostMessageToDocument(
62 int client_id, 63 int client_id,
63 const base::string16& message, 64 const base::string16& message,
64 scoped_ptr<blink::WebMessagePortChannelArray> channels); 65 scoped_ptr<blink::WebMessagePortChannelArray> channels);
66 void SkipWaiting(blink::WebCallback* callback);
65 67
66 // Send a message to the browser. Takes ownership of |message|. 68 // Send a message to the browser. Takes ownership of |message|.
67 void Send(IPC::Message* message); 69 void Send(IPC::Message* message);
68 70
69 // Get routing_id for sending message to the ServiceWorkerVersion 71 // Get routing_id for sending message to the ServiceWorkerVersion
70 // in the browser process. 72 // in the browser process.
71 int GetRoutingID() const; 73 int GetRoutingID() const;
72 74
73 blink::WebServiceWorkerCacheStorage* cache_storage() { 75 blink::WebServiceWorkerCacheStorage* cache_storage() {
74 return cache_storage_dispatcher_.get(); 76 return cache_storage_dispatcher_.get();
75 } 77 }
76 78
77 private: 79 private:
78 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> 80 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer>
79 ClientsCallbacksMap; 81 ClientsCallbacksMap;
80 82 typedef IDMap<blink::WebCallback, IDMapOwnPointer> SkipWaitingCallbacksMap;
81 83
82 void OnActivateEvent(int request_id); 84 void OnActivateEvent(int request_id);
83 void OnInstallEvent(int request_id, int active_version_id); 85 void OnInstallEvent(int request_id, int active_version_id);
84 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); 86 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request);
85 void OnSyncEvent(int request_id); 87 void OnSyncEvent(int request_id);
86 void OnPushEvent(int request_id, const std::string& data); 88 void OnPushEvent(int request_id, const std::string& data);
87 void OnGeofencingEvent(int request_id, 89 void OnGeofencingEvent(int request_id,
88 blink::WebGeofencingEventType event_type, 90 blink::WebGeofencingEventType event_type,
89 const std::string& region_id, 91 const std::string& region_id,
90 const blink::WebCircularGeofencingRegion& region); 92 const blink::WebCircularGeofencingRegion& region);
91 void OnPostMessage(const base::string16& message, 93 void OnPostMessage(const base::string16& message,
92 const std::vector<int>& sent_message_port_ids, 94 const std::vector<int>& sent_message_port_ids,
93 const std::vector<int>& new_routing_ids); 95 const std::vector<int>& new_routing_ids);
94 void OnDidGetClientDocuments( 96 void OnDidGetClientDocuments(
95 int request_id, const std::vector<int>& client_ids); 97 int request_id, const std::vector<int>& client_ids);
98 void OnDidSkipWaiting(int request_id);
96 99
97 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; 100 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_;
98 101
99 // Not owned; embedded_context_ owns this. 102 // Not owned; embedded_context_ owns this.
100 EmbeddedWorkerContextClient* embedded_context_; 103 EmbeddedWorkerContextClient* embedded_context_;
101 104
102 // Not owned; this object is destroyed when proxy_ becomes invalid. 105 // Not owned; this object is destroyed when proxy_ becomes invalid.
103 blink::WebServiceWorkerContextProxy* proxy_; 106 blink::WebServiceWorkerContextProxy* proxy_;
104 107
105 // Used for incoming messages from the browser for which an outgoing response 108 // Used for incoming messages from the browser for which an outgoing response
106 // back to the browser is expected, the id must be sent back with the 109 // back to the browser is expected, the id must be sent back with the
107 // response. 110 // response.
108 int current_request_id_; 111 int current_request_id_;
109 112
110 // Pending callbacks for GetClientDocuments(). 113 // Pending callbacks for GetClientDocuments().
111 ClientsCallbacksMap pending_clients_callbacks_; 114 ClientsCallbacksMap pending_clients_callbacks_;
112 115
116 // Pending callbacks for SkipWaiting().
117 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_;
118
113 // Capture timestamps for UMA 119 // Capture timestamps for UMA
114 std::map<int, base::TimeTicks> activate_start_timings_; 120 std::map<int, base::TimeTicks> activate_start_timings_;
115 std::map<int, base::TimeTicks> fetch_start_timings_; 121 std::map<int, base::TimeTicks> fetch_start_timings_;
116 std::map<int, base::TimeTicks> install_start_timings_; 122 std::map<int, base::TimeTicks> install_start_timings_;
117 123
118 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); 124 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext);
119 }; 125 };
120 126
121 } // namespace content 127 } // namespace content
122 128
123 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ 129 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698