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

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: Address kinuko's 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.
kinuko 2013/12/04 13:04:29 Some files have (c) while others do not. Afaik ou
alecflett 2013/12/06 05:43:33 Whatever I check in, there's some bot that always
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_registration_status.h"
10 #include "content/browser/service_worker/service_worker_storage.h"
11
12 namespace content {
13
14 // A ServiceWorkerRegisterJob lives only for the lifetime of a single
15 // registration or unregistration.
16 class ServiceWorkerRegisterJob {
17 public:
18 typedef base::Callback<
19 void(ServiceWorkerRegisterJob*,
20 ServiceWorkerRegistrationStatus status,
21 ServiceWorkerRegistration*)> RegistrationCompleteCallback;
22
23 // All type of jobs (Register and Unregister) complete through a
24 // single call to this callback on the IO thread.
25 ServiceWorkerRegisterJob(const base::WeakPtr<ServiceWorkerStorage>& storage,
26 const RegistrationCompleteCallback& callback);
27 ~ServiceWorkerRegisterJob();
28
29 // The Registration flow includes most or all of the following,
30 // depending on what is already registered:
31 // - creating a ServiceWorkerRegistration instance if there isn't
32 // already something registered
33 // - creating a ServiceWorkerVersion for the new registration instance.
34 // - starting a worker for the ServiceWorkerVersion
35 // - telling the Version to evaluate the script
36 // - firing the 'install' event at the ServiceWorkerVersion
37 // - firing the 'activate' event at the ServiceWorkerVersion
38 // - Waiting for older ServiceWorkerVersions to deactivate
39 // - designating the new version to be the 'active' version
40 // This method should be called once and only once per job.
kinuko 2013/12/04 13:04:29 To perform all these operations would Storage be t
alecflett 2013/12/06 05:43:33 I think as far as owning the Job class instance, i
41 void StartRegister(const GURL& pattern, const GURL& script_url);
42
43 // The Unregistration process is primarily cleanup, removing
44 // everything that was created during the Registration process,
45 // including the ServiceWorkerRegistration itself.
46 // This method should be called once and only once per job.
47 void StartUnregister(const GURL& pattern);
48
49 private:
50 // These are all steps in the registration and unregistration pipeline.
51 void RegisterPatternAndContinue(
52 const GURL& pattern,
53 const GURL& script_url,
54 const ServiceWorkerStorage::RegistrationCallback& callback,
55 ServiceWorkerRegistrationStatus previous_status);
56
57 void UnregisterPatternAndContinue(
58 const GURL& pattern,
59 const GURL& script_url,
60 const ServiceWorkerStorage::UnregistrationCallback& callback,
61 ServiceWorkerRegistrationStatus previous_status,
62 const scoped_refptr<ServiceWorkerRegistration>& previous_registration);
63
64 // These methods convert
kinuko 2013/12/04 13:04:29 incomplete sentence?
alecflett 2013/12/06 05:43:33 Done.
65 void UnregisterComplete(ServiceWorkerRegistrationStatus status);
66 void RegisterComplete(
67 ServiceWorkerRegistrationStatus status,
68 const scoped_refptr<ServiceWorkerRegistration>& registration);
69
70 const base::WeakPtr<ServiceWorkerStorage> storage_;
71 const RegistrationCompleteCallback callback_;
72 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
73
74 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
75 };
76 } // namespace content
77
78 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698