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

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

Issue 140743012: Start EmbeddedWorker during registration - take 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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_REGISTER_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/service_worker/service_worker_registration_status.h" 11 #include "content/browser/service_worker/service_worker_registration_status.h"
12 #include "content/browser/service_worker/service_worker_storage.h" 12 #include "content/browser/service_worker/service_worker_storage.h"
13 #include "content/browser/service_worker/service_worker_version.h"
14 #include "content/browser/service_worker/service_worker_version_status.h"
13 15
14 namespace content { 16 namespace content {
15 17
18 class EmbeddedWorkerRegistry;
16 class ServiceWorkerJobCoordinator; 19 class ServiceWorkerJobCoordinator;
17 20
18 // A ServiceWorkerRegisterJob lives only for the lifetime of a single 21 // A ServiceWorkerRegisterJob lives only for the lifetime of a single
19 // registration or unregistration. 22 // registration or unregistration.
20 class ServiceWorkerRegisterJob { 23 class ServiceWorkerRegisterJob {
21 public: 24 public:
22 enum RegistrationType { 25 enum RegistrationType {
23 REGISTER, 26 REGISTER,
24 UNREGISTER, 27 UNREGISTER,
25 }; 28 };
26 29
27 typedef base::Callback<void(ServiceWorkerRegistrationStatus status, 30 typedef base::Callback<void(ServiceWorkerRegistrationStatus status,
28 const scoped_refptr<ServiceWorkerRegistration>& 31 const scoped_refptr<ServiceWorkerRegistration>&
29 registration)> RegistrationCallback; 32 registration)> RegistrationCallback;
30 typedef base::Callback<void(ServiceWorkerRegistrationStatus status)> 33 typedef base::Callback<void(ServiceWorkerRegistrationStatus status)>
31 UnregistrationCallback; 34 UnregistrationCallback;
32 35
33 // All type of jobs (Register and Unregister) complete through a 36 // All type of jobs (Register and Unregister) complete through a
34 // single call to this callback on the IO thread. 37 // single call to this callback on the IO thread.
35 ServiceWorkerRegisterJob(ServiceWorkerStorage* storage, 38 ServiceWorkerRegisterJob(ServiceWorkerStorage* storage,
39 EmbeddedWorkerRegistry* worker_registry,
36 ServiceWorkerJobCoordinator* coordinator, 40 ServiceWorkerJobCoordinator* coordinator,
37 const GURL& pattern, 41 const GURL& pattern,
38 const GURL& script_url, 42 const GURL& script_url,
39 RegistrationType type); 43 RegistrationType type);
40 ~ServiceWorkerRegisterJob(); 44 ~ServiceWorkerRegisterJob();
41 45
42 void AddCallback(const RegistrationCallback& callback); 46 void AddCallback(const RegistrationCallback& callback,
47 ServiceWorkerProviderHost* source_provider);
43 48
44 void Start(); 49 void Start();
45 50
46 bool Equals(ServiceWorkerRegisterJob* job); 51 bool Equals(ServiceWorkerRegisterJob* job);
47 52
48 private: 53 private:
49 // The Registration flow includes most or all of the following, 54 // The Registration flow includes most or all of the following,
50 // depending on what is already registered: 55 // depending on what is already registered:
51 // - creating a ServiceWorkerRegistration instance if there isn't 56 // - creating a ServiceWorkerRegistration instance if there isn't
52 // already something registered 57 // already something registered
(...skipping 17 matching lines...) Expand all
70 void RegisterPatternAndContinue( 75 void RegisterPatternAndContinue(
71 const RegistrationCallback& callback, 76 const RegistrationCallback& callback,
72 ServiceWorkerRegistrationStatus previous_status); 77 ServiceWorkerRegistrationStatus previous_status);
73 78
74 void UnregisterPatternAndContinue( 79 void UnregisterPatternAndContinue(
75 const UnregistrationCallback& callback, 80 const UnregistrationCallback& callback,
76 bool found, 81 bool found,
77 ServiceWorkerRegistrationStatus previous_status, 82 ServiceWorkerRegistrationStatus previous_status,
78 const scoped_refptr<ServiceWorkerRegistration>& previous_registration); 83 const scoped_refptr<ServiceWorkerRegistration>& previous_registration);
79 84
85 void StartWorkerAndContinue(
86 const base::Callback<void(ServiceWorkerRegistrationStatus,
87 const scoped_refptr<ServiceWorkerRegistration>&,
88 ServiceWorkerVersionStatus)> callback,
89 ServiceWorkerRegistrationStatus status,
90 const scoped_refptr<ServiceWorkerRegistration>& registration);
91
80 // These methods are the last internal callback in the callback 92 // These methods are the last internal callback in the callback
81 // chain, and ultimately call callback_. 93 // chain, and ultimately call callback_.
82 void UnregisterComplete(ServiceWorkerRegistrationStatus status); 94 void UnregisterComplete(ServiceWorkerRegistrationStatus status);
83 void RegisterComplete( 95 void RegisterComplete(
84 ServiceWorkerRegistrationStatus status, 96 ServiceWorkerRegistrationStatus status,
85 const scoped_refptr<ServiceWorkerRegistration>& registration); 97 const scoped_refptr<ServiceWorkerRegistration>& registration,
98 ServiceWorkerVersionStatus version_status);
86 99
87 void RunCallbacks( 100 void RunCallbacks(
88 ServiceWorkerRegistrationStatus status, 101 ServiceWorkerRegistrationStatus status,
89 const scoped_refptr<ServiceWorkerRegistration>& registration); 102 const scoped_refptr<ServiceWorkerRegistration>& registration);
90 103
91 // The ServiceWorkerStorage object should always outlive 104 // The ServiceWorkerStorage object should always outlive
92 // this. 105 // this.
93 106
94 // TODO(alecflett) When we support job cancelling, if we are keeping 107 // TODO(alecflett) When we support job cancelling, if we are keeping
95 // this job alive for any reason, be sure to clear this variable, 108 // this job alive for any reason, be sure to clear this variable,
96 // because we may be cancelling while there are outstanding 109 // because we may be cancelling while there are outstanding
97 // callbacks that expect access to storage_. 110 // callbacks that expect access to storage_.
98 ServiceWorkerStorage* storage_; 111 ServiceWorkerStorage* storage_;
112 EmbeddedWorkerRegistry* worker_registry_;
99 ServiceWorkerJobCoordinator* coordinator_; 113 ServiceWorkerJobCoordinator* coordinator_;
114 scoped_refptr<ServiceWorkerVersion> pending_version_;
100 const GURL pattern_; 115 const GURL pattern_;
101 const GURL script_url_; 116 const GURL script_url_;
102 const RegistrationType type_; 117 const RegistrationType type_;
103 std::vector<RegistrationCallback> callbacks_; 118 std::vector<RegistrationCallback> callbacks_;
119 std::vector<ServiceWorkerProviderHost*> pending_provider_hosts_;
104 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; 120 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
105 121
106 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); 122 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
107 }; 123 };
108 } // namespace content 124 } // namespace content
109 125
110 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 126 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698