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

Unified Diff: content/public/browser/resource_throttle.h

Issue 2535723005: Stop using ResourceController in ResourceThrottle (Closed)
Patch Set: Addressed #62 Created 4 years 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
« no previous file with comments | « content/browser/loader/throttling_resource_handler.cc ('k') | content/public/browser/resource_throttle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/resource_throttle.h
diff --git a/content/public/browser/resource_throttle.h b/content/public/browser/resource_throttle.h
index da1054c86cfb5c26bf2890fa82190fcb934c2400..4ac8fd4d6633197eaf37c740470090a1150630be 100644
--- a/content/public/browser/resource_throttle.h
+++ b/content/public/browser/resource_throttle.h
@@ -24,6 +24,25 @@ class ThrottlingResourceHandler;
// time.
class CONTENT_EXPORT ResourceThrottle {
public:
+ // An interface to get notified when the throttle implementation considers
+ // it's ready to resume the deferred resource load. The throttle
+ // implementation may also tell the delegate to cancel the resource loading.
+ class CONTENT_EXPORT Delegate {
+ public:
+ // Cancels the resource load.
+ virtual void Cancel() = 0;
+ // Marks the resource load as ignored by the resource handler, and then
+ // cancels the resource load.
+ virtual void CancelAndIgnore() = 0;
+ // Cancels the resource load with the specified error code.
+ virtual void CancelWithError(int error_code) = 0;
+ // Tells the delegate to resume the deferred resource load.
+ virtual void Resume() = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
virtual ~ResourceThrottle() {}
// Called before the resource request is started.
@@ -51,20 +70,25 @@ class CONTENT_EXPORT ResourceThrottle {
// WillProcessResponse.
virtual bool MustProcessResponseBeforeReadingBody();
- void set_controller_for_testing(ResourceController* c) {
- controller_ = c;
- }
+ void set_delegate_for_testing(Delegate* delegate) { delegate_ = delegate; }
protected:
- ResourceThrottle() : controller_(nullptr) {}
- ResourceController* controller() { return controller_; }
+ ResourceThrottle() : delegate_(nullptr) {}
+
+ // Helper methods for subclasses. When these methods are called, methods with
+ // the same name on |delegate_| are called.
+ void Cancel();
+ void CancelAndIgnore();
+ void CancelWithError(int error_code);
+ void Resume();
private:
friend class AsyncRevalidationDriver;
friend class ThrottlingResourceHandler;
- void set_controller(ResourceController* c) { controller_ = c; }
- ResourceController* controller_;
+ void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+
+ Delegate* delegate_;
};
} // namespace content
« no previous file with comments | « content/browser/loader/throttling_resource_handler.cc ('k') | content/public/browser/resource_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698