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

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

Issue 2874073004: network service: Add job wrapper to SWControlleeRequestHandler (Closed)
Patch Set: . Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
7
8 #include "base/macros.h"
9 #include "content/browser/service_worker/service_worker_url_request_job.h"
10
11 namespace content {
12
13 // TODO(scottmg): Not yet implemented. See https://crbug.com/715640.
14 class ServiceWorkerControlleeURLLoaderFactory;
15
16 // This class is a helper to support having
17 // ServiceWorkerControlleeRequestHandler work with both URLRequestJobs and
18 // mojom::URLLoaderFactorys (that is, both with and without
19 // --enable-network-service). It wraps either a ServiceWorkerURLRequestJob or a
20 // ServiceWorkerControlleeRequestHandler and forwards to the underlying
21 // implementation.
22 class ServiceWorkerJobWrapper {
23 public:
24 // Non-network service case.
25 explicit ServiceWorkerJobWrapper(
26 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job);
27
28 // With --enable-network-service.
29 explicit ServiceWorkerJobWrapper(
30 ServiceWorkerControlleeURLLoaderFactory* factory);
kinuko 2017/05/11 12:48:53 I wonder if this should rather wrap urlloader?
scottmg 2017/05/16 18:28:51 I'm not 100% sure if that will work yet, but that
31
32 ~ServiceWorkerJobWrapper();
33
34 // Sets the response type.
35 void FallbackToNetwork();
36 void FallbackToNetworkOrRenderer();
37 void ForwardToServiceWorker();
38
39 // Returns true if this job should not be handled by a service worker, but
40 // instead should fallback to the network.
41 bool ShouldFallbackToNetwork();
42
43 // Tells the job to abort with a start error. Currently this is only called
44 // because the controller was lost. This function could be made more generic
45 // if needed later.
46 void FailDueToLostController();
47
48 // Determines from the ResourceRequestInfo (or similar) the type of page
49 // transition used (for metrics purposes).
50 ui::PageTransition GetPageTransition();
51
52 // Determines the number of redirects used to handle the job (for metrics
53 // purposes).
54 size_t GetURLChainSize() const;
kinuko 2017/05/11 12:48:53 I feel in the new code the job wouldn't know these
scottmg 2017/05/16 18:28:51 Yeah, probably right. Since they're "only" for met
55
56 // Returns true if the underlying job has been canceled or destroyed.
57 bool WasCanceled() const;
58
59 private:
60 base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job_;
61 ServiceWorkerControlleeURLLoaderFactory* factory_;
62
63 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerJobWrapper);
64 };
65
66 } // namespace content
67
68 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698