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

Unified Diff: content/browser/frame_host/navigation_request.h

Issue 475783002: PlzNavigate: add cancel navigation logic for uncommitted requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the actual calls to cancel the navigation request Created 6 years, 4 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/frame_host/navigation_request.h
diff --git a/content/browser/frame_host/navigation_request.h b/content/browser/frame_host/navigation_request.h
index 6cc1cd2fe98b6bcaf4a44e74ae2e4f66ffeb3eca..c9f7fdbaa2776fbdff8ae586cdd183354c53fd79 100644
--- a/content/browser/frame_host/navigation_request.h
+++ b/content/browser/frame_host/navigation_request.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/browser/frame_host/navigation_request_info.h"
+#include "content/common/content_export.h"
namespace content {
class ResourceRequestBody;
@@ -20,21 +21,59 @@ class ResourceRequestBody;
// the navigation following its refactoring.
class NavigationRequest {
public:
+
+ // Implementors of NavigationRequest::Observer will be notified of important
+ // events happening in the life-cycle of the NavigationRequest instance they
+ // register for.
+ class Observer {
clamy 2014/08/28 12:17:01 The CONTENT_EXPORT should be placed before the cla
(Do not use) nasko 2014/08/28 15:55:05 This class doesn't seem to follow very well how ot
+ public:
+ CONTENT_EXPORT Observer();
clamy 2014/08/28 12:17:01 The constructors and the destructor should be prot
carlosk 2014/08/29 15:54:43 Done.
+
+ CONTENT_EXPORT explicit Observer(NavigationRequest* nv);
+
+ CONTENT_EXPORT virtual ~Observer();
+
+ virtual void RequestCanceled(NavigationRequest* nv) = 0;
+
+ virtual void RequestDestroyed(NavigationRequest* nv) = 0;
+
+ // NOTE: This method is automatically called by NavigationRequest when an
+ // observer is set to it. Users should not need to do this manually.
+ void set_navigation_request(NavigationRequest* nv) {
clamy 2014/08/28 12:17:01 With further reading of the code, it is apparently
+ navigation_request_ = nv; }
+
+ private:
+ NavigationRequest* navigation_request_;
+ };
+
NavigationRequest(const NavigationRequestInfo& info, int64 frame_node_id);
~NavigationRequest();
- const NavigationRequestInfo& info() const { return info_; }
- int64 frame_node_id() const { return frame_node_id_; }
-
// Called on the UI thread by the RenderFrameHostManager which owns the
// NavigationRequest. After calling this function, |body| can no longer be
// manipulated on the UI thread.
void BeginNavigation(scoped_refptr<ResourceRequestBody> body);
+ // Called on the UI thread by the RenderFrameHostManager which owns the
+ // NavigationRequest whenever this navigation request should be canceled.
+ void CancelNavigation();
+
+ // Used to register and unregister a single observer for this instance. This
+ // call automatically sets the navigation request instance into the observer.
+ void SetSingleObserver(NavigationRequest::Observer* observer);
+
+ const NavigationRequestInfo& info() const { return info_; }
+
+ int64 frame_node_id() const { return frame_node_id_; }
+
+ int64 navigation_request_id() const { return navigation_request_id_; }
+
private:
+ const int64 navigation_request_id_;
const NavigationRequestInfo info_;
const int64 frame_node_id_;
+ Observer* single_observer_;
clamy 2014/08/28 12:17:01 I really don't like this single observer pattern.
DISALLOW_COPY_AND_ASSIGN(NavigationRequest);
};

Powered by Google App Engine
This is Rietveld 408576698