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

Side by Side Diff: content/browser/service_worker/service_worker_version.h

Issue 286203008: Revert of Stop ServiceWorker context when no controllee is associated (and when all refs are dropped) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/id_map.h" 13 #include "base/id_map.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/timer/timer.h"
18 #include "content/browser/service_worker/embedded_worker_instance.h" 17 #include "content/browser/service_worker/embedded_worker_instance.h"
19 #include "content/browser/service_worker/service_worker_script_cache_map.h" 18 #include "content/browser/service_worker/service_worker_script_cache_map.h"
20 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
21 #include "content/common/service_worker/service_worker_status_code.h" 20 #include "content/common/service_worker/service_worker_status_code.h"
22 #include "content/common/service_worker/service_worker_types.h" 21 #include "content/common/service_worker/service_worker_types.h"
23 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" 22 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
24 23
25 class GURL; 24 class GURL;
26 25
27 namespace content { 26 namespace content {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 181
183 // Returns true if this has at least one process to run. 182 // Returns true if this has at least one process to run.
184 bool HasProcessToRun() const; 183 bool HasProcessToRun() const;
185 184
186 // Adds and removes |provider_host| as a controllee of this ServiceWorker. 185 // Adds and removes |provider_host| as a controllee of this ServiceWorker.
187 void AddControllee(ServiceWorkerProviderHost* provider_host); 186 void AddControllee(ServiceWorkerProviderHost* provider_host);
188 void RemoveControllee(ServiceWorkerProviderHost* provider_host); 187 void RemoveControllee(ServiceWorkerProviderHost* provider_host);
189 void AddPendingControllee(ServiceWorkerProviderHost* provider_host); 188 void AddPendingControllee(ServiceWorkerProviderHost* provider_host);
190 void RemovePendingControllee(ServiceWorkerProviderHost* provider_host); 189 void RemovePendingControllee(ServiceWorkerProviderHost* provider_host);
191 190
192 // Returns if it has controllee. 191 // Returns if it has (non-pending) controllee.
193 bool HasControllee() const { return !controllee_map_.empty(); } 192 bool HasControllee() const { return !controllee_map_.empty(); }
194 193
195 // Adds and removes Listeners. 194 // Adds and removes Listeners.
196 void AddListener(Listener* listener); 195 void AddListener(Listener* listener);
197 void RemoveListener(Listener* listener); 196 void RemoveListener(Listener* listener);
198 197
199 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } 198 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; }
200 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } 199 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); }
201 200
202 private: 201 private:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 void OnInstallEventFinished(int request_id, 233 void OnInstallEventFinished(int request_id,
235 blink::WebServiceWorkerEventResult result); 234 blink::WebServiceWorkerEventResult result);
236 void OnFetchEventFinished(int request_id, 235 void OnFetchEventFinished(int request_id,
237 ServiceWorkerFetchEventResult result, 236 ServiceWorkerFetchEventResult result,
238 const ServiceWorkerResponse& response); 237 const ServiceWorkerResponse& response);
239 void OnSyncEventFinished(int request_id); 238 void OnSyncEventFinished(int request_id);
240 void OnPostMessageToDocument(int client_id, 239 void OnPostMessageToDocument(int client_id,
241 const base::string16& message, 240 const base::string16& message,
242 const std::vector<int>& sent_message_port_ids); 241 const std::vector<int>& sent_message_port_ids);
243 242
244 void ScheduleStopWorker();
245
246 const int64 version_id_; 243 const int64 version_id_;
247 int64 registration_id_; 244 int64 registration_id_;
248 GURL script_url_; 245 GURL script_url_;
249 GURL scope_; 246 GURL scope_;
250 Status status_; 247 Status status_;
251 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 248 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
252 std::vector<StatusCallback> start_callbacks_; 249 std::vector<StatusCallback> start_callbacks_;
253 std::vector<StatusCallback> stop_callbacks_; 250 std::vector<StatusCallback> stop_callbacks_;
254 std::vector<base::Closure> status_change_callbacks_; 251 std::vector<base::Closure> status_change_callbacks_;
255 252
256 // Message callbacks. 253 // Message callbacks.
257 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 254 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
258 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 255 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
259 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 256 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
260 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 257 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
261 258
262 ControlleeMap controllee_map_; 259 ControlleeMap controllee_map_;
263 ControlleeByIDMap controllee_by_id_; 260 ControlleeByIDMap controllee_by_id_;
264 base::WeakPtr<ServiceWorkerContextCore> context_; 261 base::WeakPtr<ServiceWorkerContextCore> context_;
265 ObserverList<Listener> listeners_; 262 ObserverList<Listener> listeners_;
266 ServiceWorkerScriptCacheMap script_cache_map_; 263 ServiceWorkerScriptCacheMap script_cache_map_;
267 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
268 264
269 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 265 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
270 266
271 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 267 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
272 }; 268 };
273 269
274 } // namespace content 270 } // namespace content
275 271
276 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 272 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698