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

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

Issue 62203007: Implement memory-persistent registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More comments Created 7 years 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "content/browser/service_worker/service_worker_storage.h"
10
11 namespace content {
12
13 // A ServiceWorkerRegisterJob lives only for the lifetime of a single
14 // registration or unregistration.
15 class ServiceWorkerRegisterJob {
16 public:
17 typedef base::Callback<
18 void(ServiceWorkerRegisterJob*,
19 ServiceWorkerStorage::RegistrationStatus status,
20 ServiceWorkerRegistration*)> RegistrationCompleteCallback;
21
22 // All type of jobs (Register and Unregister) complete through a
23 // single call to this callback on the IO thread.
24 ServiceWorkerRegisterJob(const base::WeakPtr<ServiceWorkerStorage>& storage,
25 const RegistrationCompleteCallback& callback);
26 ~ServiceWorkerRegisterJob();
27
28 // The Registration flow includes most or all of the following,
29 // depending on what is already registered:
30 // - creating a ServiceWorkerRegistration instance if there isn't
31 // already something registered
32 // - creating a ServiceWorkerVersion for the new registration instance.
33 // - starting a worker for the ServiceWorkerVersion
34 // - telling the Version to evaluate the script
35 // - firing the 'install' event at the ServiceWorkerVersion
36 // - firing the 'activate' event at the ServiceWorkerVersion
37 // - Waiting for older ServiceWorkerVersions to deactivate
38 // - designating the new version to be the 'active' version
39 void StartRegister(const GURL& pattern, const GURL& script_url);
40
41 // The Unregistration process is primarily cleanup, removing
42 // everything that was created during the Registration process,
43 // including the ServiceWorkerRegistration itself.
44 void StartUnregister(const GURL& pattern);
kinuko 2013/11/27 03:45:23 It's one off operation class, I think ideally havi
alecflett 2013/12/02 16:11:35 I'd like to avoid doing that just yet. They share
45
46 private:
47 // These are all steps in the registration and unregistration pipeline.
48 void RegisterPatternAndContinue(
49 const GURL& pattern,
50 const GURL& script_url,
51 const ServiceWorkerStorage::RegistrationCallback& callback,
52 ServiceWorkerStorage::RegistrationStatus previous_status);
53
54 void UnregisterPatternAndContinue(
55 const GURL& pattern,
56 const GURL& script_url,
57 const ServiceWorkerStorage::UnregistrationCallback& callback,
58 ServiceWorkerStorage::RegistrationStatus previous_status,
59 const scoped_refptr<ServiceWorkerRegistration>& previous_registration);
60
61 // These methods convert
62 void UnregisterComplete(ServiceWorkerStorage::RegistrationStatus status);
63 void RegisterComplete(
64 ServiceWorkerStorage::RegistrationStatus status,
65 const scoped_refptr<ServiceWorkerRegistration>& registration);
66
67 const base::WeakPtr<ServiceWorkerStorage> storage_;
68 const RegistrationCompleteCallback callback_;
69 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
72 };
73 } // namespace content
74
75 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698