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

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

Issue 1710903002: Revert of service worker: use 200 OK for update requests even in the no update case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 <string>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
13 #include "content/browser/service_worker/embedded_worker_instance.h" 12 #include "content/browser/service_worker/embedded_worker_instance.h"
14 #include "content/browser/service_worker/service_worker_register_job_base.h" 13 #include "content/browser/service_worker/service_worker_register_job_base.h"
15 #include "content/browser/service_worker/service_worker_registration.h" 14 #include "content/browser/service_worker/service_worker_registration.h"
16 #include "content/common/service_worker/service_worker_status_code.h" 15 #include "content/common/service_worker/service_worker_status_code.h"
17 #include "url/gurl.h" 16 #include "url/gurl.h"
18 17
19 namespace content { 18 namespace content {
20 19
21 class ServiceWorkerJobCoordinator; 20 class ServiceWorkerJobCoordinator;
22 class ServiceWorkerStorage; 21 class ServiceWorkerStorage;
23 22
24 // Handles the initial registration of a Service Worker and the 23 // Handles the initial registration of a Service Worker and the
25 // subsequent update of existing registrations. 24 // subsequent update of existing registrations.
26 // 25 //
27 // The control flow includes most or all of the following, 26 // The control flow includes most or all of the following,
28 // depending on what is already registered: 27 // depending on what is already registered:
29 // - creating a ServiceWorkerRegistration instance if there isn't 28 // - creating a ServiceWorkerRegistration instance if there isn't
30 // already something registered 29 // already something registered
31 // - creating a ServiceWorkerVersion for the new version. 30 // - creating a ServiceWorkerVersion for the new version.
32 // - starting a worker for the ServiceWorkerVersion 31 // - starting a worker for the ServiceWorkerVersion
33 // - firing the 'install' event at the ServiceWorkerVersion 32 // - firing the 'install' event at the ServiceWorkerVersion
34 // - firing the 'activate' event at the ServiceWorkerVersion 33 // - firing the 'activate' event at the ServiceWorkerVersion
35 // - waiting for older ServiceWorkerVersions to deactivate 34 // - waiting for older ServiceWorkerVersions to deactivate
36 // - designating the new version to be the 'active' version 35 // - designating the new version to be the 'active' version
37 // - updating storage 36 // - updating storage
38 class ServiceWorkerRegisterJob : public ServiceWorkerRegisterJobBase, 37 class ServiceWorkerRegisterJob : public ServiceWorkerRegisterJobBase {
39 public EmbeddedWorkerInstance::Listener {
40 public: 38 public:
41 typedef base::Callback<void(ServiceWorkerStatusCode status, 39 typedef base::Callback<void(ServiceWorkerStatusCode status,
42 const std::string& status_message, 40 const std::string& status_message,
43 ServiceWorkerRegistration* registration)> 41 ServiceWorkerRegistration* registration)>
44 RegistrationCallback; 42 RegistrationCallback;
45 43
46 // For registration jobs. 44 // For registration jobs.
47 CONTENT_EXPORT ServiceWorkerRegisterJob( 45 CONTENT_EXPORT ServiceWorkerRegisterJob(
48 base::WeakPtr<ServiceWorkerContextCore> context, 46 base::WeakPtr<ServiceWorkerContextCore> context,
49 const GURL& pattern, 47 const GURL& pattern,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const std::string& status_message); 127 const std::string& status_message);
130 void CompleteInternal(ServiceWorkerStatusCode status, 128 void CompleteInternal(ServiceWorkerStatusCode status,
131 const std::string& status_message); 129 const std::string& status_message);
132 void ResolvePromise(ServiceWorkerStatusCode status, 130 void ResolvePromise(ServiceWorkerStatusCode status,
133 const std::string& status_message, 131 const std::string& status_message,
134 ServiceWorkerRegistration* registration); 132 ServiceWorkerRegistration* registration);
135 133
136 void AddRegistrationToMatchingProviderHosts( 134 void AddRegistrationToMatchingProviderHosts(
137 ServiceWorkerRegistration* registration); 135 ServiceWorkerRegistration* registration);
138 136
139 // EmbeddedWorkerInstance::Listener implementation:
140 void OnScriptLoaded() override;
141
142 // The ServiceWorkerContextCore object should always outlive this. 137 // The ServiceWorkerContextCore object should always outlive this.
143 base::WeakPtr<ServiceWorkerContextCore> context_; 138 base::WeakPtr<ServiceWorkerContextCore> context_;
144 139
145 RegistrationJobType job_type_; 140 RegistrationJobType job_type_;
146 const GURL pattern_; 141 const GURL pattern_;
147 const GURL script_url_; 142 const GURL script_url_;
148 std::vector<RegistrationCallback> callbacks_; 143 std::vector<RegistrationCallback> callbacks_;
149 Phase phase_; 144 Phase phase_;
150 Internal internal_; 145 Internal internal_;
151 bool doom_installing_worker_; 146 bool doom_installing_worker_;
152 bool is_promise_resolved_; 147 bool is_promise_resolved_;
153 bool should_uninstall_on_failure_; 148 bool should_uninstall_on_failure_;
154 bool force_bypass_cache_; 149 bool force_bypass_cache_;
155 bool skip_script_comparison_; 150 bool skip_script_comparison_;
156 ServiceWorkerStatusCode promise_resolved_status_; 151 ServiceWorkerStatusCode promise_resolved_status_;
157 std::string promise_resolved_status_message_; 152 std::string promise_resolved_status_message_;
158 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_; 153 scoped_refptr<ServiceWorkerRegistration> promise_resolved_registration_;
159 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_; 154 base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
160 155
161 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob); 156 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
162 }; 157 };
163 158
164 } // namespace content 159 } // namespace content
165 160
166 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_ 161 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698