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

Unified Diff: content/browser/loader/url_loader_request_handler.h

Issue 2897063002: Network service: Implement URLLoader chaining for interceptors (Closed)
Patch Set: documentation 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/loader/url_loader_request_handler.h
diff --git a/content/browser/loader/url_loader_request_handler.h b/content/browser/loader/url_loader_request_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..f72cc2a88e5d2cd45ef1d7ef6356387276b4cd1f
--- /dev/null
+++ b/content/browser/loader/url_loader_request_handler.h
@@ -0,0 +1,46 @@
+// 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_LOADER_URL_LOADER_REQUEST_HANDLER_H_
+#define CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "content/common/url_loader_factory.mojom.h"
+
+namespace content {
+
+class ResourceContext;
+struct ResourceRequest;
+
+using LoaderFactoryCallback =
+ base::OnceCallback<void(mojom::URLLoaderFactory*)>;
+
+// An instance of this class is a per-request object and kept around during
+// the lifetime of a request (including multiple redirect legs) on IO thread.
+class CONTENT_EXPORT URLLoaderRequestHandler {
+ public:
+ URLLoaderRequestHandler() = default;
+ virtual ~URLLoaderRequestHandler() = default;
+
+ // Calls |callback| with non-null factory if this handler can handle
+ // the request, calls it with nullptr otherwise.
+ // Some implementation notes:
+ // 1) The returned pointer needs to be valid only until a single
+ // CreateLoaderAndStart call is made, and it is okay to do CHECK(false) for
+ // any subsequent calls.
+ // 2) The implementor is not supposed to set up and return URLLoaderFactory
+ // until it finds out that the handler is really going to handle the
+ // request. (For example ServiceWorker's request handler would not need to
+ // call the callback until it gets response from SW, and it may still
+ // call the callback with nullptr if it turns out that it needs to fallback
+ // to the network.)
+ virtual void MaybeCreateLoaderFactory(const ResourceRequest& resource_request,
+ ResourceContext* resource_context,
+ LoaderFactoryCallback callback) = 0;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698