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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_job_wrapper.h
diff --git a/content/browser/service_worker/service_worker_job_wrapper.h b/content/browser/service_worker/service_worker_job_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..eff5a14ce1458fbd812e93d71ac8b1dc9ebd6a63
--- /dev/null
+++ b/content/browser/service_worker/service_worker_job_wrapper.h
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_
+
+#include "base/macros.h"
+#include "content/browser/service_worker/service_worker_url_request_job.h"
+
+namespace content {
+
+// TODO(scottmg): Not yet implemented. See https://crbug.com/715640.
+class ServiceWorkerControlleeURLLoaderFactory;
+
+// This class is a helper to support having
+// ServiceWorkerControlleeRequestHandler work with both URLRequestJobs and
+// mojom::URLLoaderFactorys (that is, both with and without
+// --enable-network-service). It wraps either a ServiceWorkerURLRequestJob or a
+// ServiceWorkerControlleeRequestHandler and forwards to the underlying
+// implementation.
+class ServiceWorkerJobWrapper {
+ public:
+ // Non-network service case.
+ explicit ServiceWorkerJobWrapper(
+ base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job);
+
+ // With --enable-network-service.
+ explicit ServiceWorkerJobWrapper(
+ 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
+
+ ~ServiceWorkerJobWrapper();
+
+ // Sets the response type.
+ void FallbackToNetwork();
+ void FallbackToNetworkOrRenderer();
+ void ForwardToServiceWorker();
+
+ // Returns true if this job should not be handled by a service worker, but
+ // instead should fallback to the network.
+ bool ShouldFallbackToNetwork();
+
+ // Tells the job to abort with a start error. Currently this is only called
+ // because the controller was lost. This function could be made more generic
+ // if needed later.
+ void FailDueToLostController();
+
+ // Determines from the ResourceRequestInfo (or similar) the type of page
+ // transition used (for metrics purposes).
+ ui::PageTransition GetPageTransition();
+
+ // Determines the number of redirects used to handle the job (for metrics
+ // purposes).
+ 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
+
+ // Returns true if the underlying job has been canceled or destroyed.
+ bool WasCanceled() const;
+
+ private:
+ base::WeakPtr<ServiceWorkerURLRequestJob> url_request_job_;
+ ServiceWorkerControlleeURLLoaderFactory* factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerJobWrapper);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_JOB_WRAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698