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

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

Issue 519533002: Initial PlzNavigate RDH-side logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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/navigation_url_loader.h
diff --git a/content/browser/loader/navigation_url_loader.h b/content/browser/loader/navigation_url_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..6638776fbc2c51d8467f6bfa82c97ae1629d26fa
--- /dev/null
+++ b/content/browser/loader/navigation_url_loader.h
@@ -0,0 +1,80 @@
+// Copyright 2014 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_NAVIGATION_URL_LOADER_H_
+#define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_
+
+#include "base/basictypes.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/content_export.h"
+
+namespace net {
+struct RedirectInfo;
+}
+
+namespace content {
+
+class BrowserContext;
+class NavigationURLLoaderFactory;
+class StreamHandle;
+class ResourceRequestBody;
+struct NavigationRequestInfo;
+struct ResourceResponse;
+
+// PlzNavigate: The navigation logic's UI thread entry point into the resource
+// loading stack. It exposes an interface to control the request prior to
+// receiving the response. If the NavigationURLLoader is destroyed before
+// OnResponseStarted is called, the request is aborted.
+class CONTENT_EXPORT NavigationURLLoader {
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Called when the request is redirected. Call FollowRedirect to continue
nasko 2014/09/24 21:15:34 What happens if FollowRedirect is not called? What
davidben 2014/10/03 16:27:52 If FollowRedirect isn't called, the request just s
+ // processing the request. Apart from the reference count on |response|,
+ // they must not be modified on the UI thread.
nasko 2014/09/24 21:15:34 nit: What is "they"?
davidben 2014/10/03 16:27:52 Removed the comment. It makes a copy of the Resour
+ virtual void OnRequestRedirected(const net::RedirectInfo& redirect_info,
+ ResourceResponse* response) = 0;
+
+ // Called when the request receives its response. No further calls will be
+ // made to the delegate. The response body is returned as a stream in
+ // |body|.
+ virtual void OnResponseStarted(ResourceResponse* response,
+ scoped_ptr<StreamHandle> body) = 0;
+
nasko 2014/09/24 21:15:34 Do we need to notify the delegate if the request r
davidben 2014/10/03 16:27:52 If it results in a download, we'll get OnRequestFa
+ // Called if the request fails before receving a response. |net_error| is a
+ // network error code for the failure.
+ virtual void OnRequestFailed(int net_error) = 0;
mmenke 2014/09/23 17:22:45 private: DISALLOW_COPY_AND_ASSIGN? Suppose it's
davidben 2014/10/03 16:27:52 Done, but it requires adding a default ctor somewh
+ };
+
+ // Creates a NavigationURLLoader. The caller is responsible for ensuring that
+ // |delegate| outlives the loader. |request_body| must not be accessed on the
+ // UI thread after this point.
+ //
+ // TODO(davidben): When navigation is disentangled from the loader, the
+ // request parameters should not come in as a navigation-specific
+ // structure. Information like has_user_gesture and
+ // should_replace_current_entry shouldn't be needed at this layer.
+ static NavigationURLLoader* Create(BrowserContext* browser_context,
+ int64 frame_tree_node_id,
+ const NavigationRequestInfo& request_info,
+ ResourceRequestBody* request_body,
+ Delegate* delegate);
+
+ // For testing purposes; sets the factory for use in testing.
+ static void SetFactoryForTesting(NavigationURLLoaderFactory* factory);
+
+ virtual ~NavigationURLLoader() {}
+
+ // Called in response to OnRequestRedirected to continue processing the
+ // request.
+ virtual void FollowRedirect() = 0;
mmenke 2014/09/23 17:22:45 private: DISALLOW_COPY_AND_ASSIGN?
davidben 2014/10/03 16:27:52 Done, but it requires adding a default ctor somewh
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_H_

Powered by Google App Engine
This is Rietveld 408576698