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

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

Issue 2919313004: Get rid of URLLoaderFactory in browser-side case (Closed)
Patch Set: . Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_JOB_WRAPPER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/loader/url_loader_request_handler.h" 10 #include "content/browser/loader/url_loader_request_handler.h"
11 #include "content/browser/service_worker/service_worker_response_type.h" 11 #include "content/browser/service_worker/service_worker_response_type.h"
12 #include "content/browser/service_worker/service_worker_url_request_job.h" 12 #include "content/browser/service_worker/service_worker_url_request_job.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 // This class is a helper to support having 16 // This class is a helper to support having
17 // ServiceWorkerControlleeRequestHandler work with both URLRequestJobs and 17 // ServiceWorkerControlleeRequestHandler work with both URLRequestJobs and
18 // mojom::URLLoaderFactorys (that is, both with and without 18 // mojom::URLLoaderFactorys (that is, both with and without
19 // --enable-network-service). It wraps either a ServiceWorkerURLRequestJob or a 19 // --enable-network-service). It wraps either a ServiceWorkerURLRequestJob or a
20 // callback for URLLoaderFactory and forwards to the underlying implementation. 20 // callback for URLLoaderFactory and forwards to the underlying implementation.
21 class ServiceWorkerURLJobWrapper { 21 class ServiceWorkerURLJobWrapper {
22 public: 22 public:
23 // Non-network service case. 23 // Non-network service case.
24 explicit ServiceWorkerURLJobWrapper( 24 explicit ServiceWorkerURLJobWrapper(
25 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job); 25 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job);
26 26
27 // With --enable-network-service. 27 // With --enable-network-service.
28 // TODO(kinuko): Implement this as a separate job class rather 28 // TODO(kinuko): Implement this as a separate job class rather
29 // than in a wrapper. 29 // than in a wrapper.
30 ServiceWorkerURLJobWrapper(LoaderFactoryCallback loader_factory_callback); 30 ServiceWorkerURLJobWrapper(URLLoaderCallback loader_callback);
31 31
32 ~ServiceWorkerURLJobWrapper(); 32 ~ServiceWorkerURLJobWrapper();
33 33
34 // Sets the response type. 34 // Sets the response type.
35 void FallbackToNetwork(); 35 void FallbackToNetwork();
36 void FallbackToNetworkOrRenderer(); 36 void FallbackToNetworkOrRenderer();
37 void ForwardToServiceWorker(); 37 void ForwardToServiceWorker();
38 38
39 // Returns true if this job should not be handled by a service worker, but 39 // Returns true if this job should not be handled by a service worker, but
40 // instead should fallback to the network. 40 // instead should fallback to the network.
(...skipping 19 matching lines...) Expand all
60 enum class JobType { kURLRequest, kURLLoader }; 60 enum class JobType { kURLRequest, kURLLoader };
61 61
62 // Used only for URLLoader case. 62 // Used only for URLLoader case.
63 // TODO(kinuko): Implement this in a separate job class rather 63 // TODO(kinuko): Implement this in a separate job class rather
64 // than in a wrapper. 64 // than in a wrapper.
65 void StartRequest(); 65 void StartRequest();
66 66
67 JobType job_type_; 67 JobType job_type_;
68 68
69 ServiceWorkerResponseType response_type_ = NOT_DETERMINED; 69 ServiceWorkerResponseType response_type_ = NOT_DETERMINED;
70 LoaderFactoryCallback loader_factory_callback_; 70 URLLoaderCallback loader_callback_;
71 71
72 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job_; 72 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job_;
73 73
74 base::WeakPtrFactory<ServiceWorkerURLJobWrapper> weak_factory_; 74 base::WeakPtrFactory<ServiceWorkerURLJobWrapper> weak_factory_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLJobWrapper); 76 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLJobWrapper);
77 }; 77 };
78 78
79 } // namespace content 79 } // namespace content
80 80
81 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_ 81 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698