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

Side by Side Diff: content/public/browser/resource_throttle.h

Issue 2535723005: Stop using ResourceController in ResourceThrottle (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_
6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_ 6 #define CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_
7 7
8 #include "content/common/content_export.h" 8 #include "content/common/content_export.h"
9 9
10 namespace net { 10 namespace net {
11 struct RedirectInfo; 11 struct RedirectInfo;
12 } 12 }
13 13
14 namespace content { 14 namespace content {
15 15
16 class AsyncRevalidationDriver; 16 class AsyncRevalidationDriver;
17 class ResourceController; 17 class ResourceController;
18 class ThrottlingResourceHandler; 18 class ThrottlingResourceHandler;
19 19
20 // A ResourceThrottle gets notified at various points during the process of 20 // A ResourceThrottle gets notified at various points during the process of
21 // loading a resource. At each stage, it has the opportunity to defer the 21 // loading a resource. At each stage, it has the opportunity to defer the
22 // resource load. The ResourceController interface may be used to resume a 22 // resource load. The ResourceController interface may be used to resume a
23 // deferred resource load, or it may be used to cancel a resource load at any 23 // deferred resource load, or it may be used to cancel a resource load at any
24 // time. 24 // time.
25 class CONTENT_EXPORT ResourceThrottle { 25 class CONTENT_EXPORT ResourceThrottle {
26 public: 26 public:
27 class CONTENT_EXPORT Delegate {
28 public:
29 virtual void Cancel() = 0;
jochen (gone - plz use gerrit) 2016/12/05 15:25:03 please add comments explaining the delegate and ev
tyoshino (SeeGerritForStatus) 2016/12/06 11:25:31 Done.
30 virtual void CancelAndIgnore() = 0;
31 virtual void CancelWithError(int error_code) = 0;
32 virtual void Resume() = 0;
33
34 protected:
35 virtual ~Delegate() {}
36 };
37
27 virtual ~ResourceThrottle() {} 38 virtual ~ResourceThrottle() {}
28 39
29 // Called before the resource request is started. 40 // Called before the resource request is started.
30 virtual void WillStartRequest(bool* defer) {} 41 virtual void WillStartRequest(bool* defer) {}
31 42
32 // Called when the request was redirected. |redirect_info| contains the 43 // Called when the request was redirected. |redirect_info| contains the
33 // redirect responses's HTTP status code and some information about the new 44 // redirect responses's HTTP status code and some information about the new
34 // request that will be sent if the redirect is followed, including the new 45 // request that will be sent if the redirect is followed, including the new
35 // URL and new method. 46 // URL and new method.
36 virtual void WillRedirectRequest(const net::RedirectInfo& redirect_info, 47 virtual void WillRedirectRequest(const net::RedirectInfo& redirect_info,
37 bool* defer) {} 48 bool* defer) {}
38 49
39 // Called when the response headers and meta data are available. 50 // Called when the response headers and meta data are available.
40 virtual void WillProcessResponse(bool* defer) {} 51 virtual void WillProcessResponse(bool* defer) {}
41 52
42 // Returns the name of the throttle, as a UTF-8 C-string, for logging 53 // Returns the name of the throttle, as a UTF-8 C-string, for logging
43 // purposes. nullptr is not allowed. Caller does *not* take ownership of the 54 // purposes. nullptr is not allowed. Caller does *not* take ownership of the
44 // returned string. 55 // returned string.
45 virtual const char* GetNameForLogging() const = 0; 56 virtual const char* GetNameForLogging() const = 0;
46 57
47 // Whether this ResourceThrottle needs to execute WillProcessResponse before 58 // Whether this ResourceThrottle needs to execute WillProcessResponse before
48 // any part of the response body is read. Normally this is false. This should 59 // any part of the response body is read. Normally this is false. This should
49 // be set to true if the ResourceThrottle wants to ensure that no part of the 60 // be set to true if the ResourceThrottle wants to ensure that no part of the
50 // response body will be cached if the request is canceled in 61 // response body will be cached if the request is canceled in
51 // WillProcessResponse. 62 // WillProcessResponse.
52 virtual bool MustProcessResponseBeforeReadingBody(); 63 virtual bool MustProcessResponseBeforeReadingBody();
53 64
54 void set_controller_for_testing(ResourceController* c) { 65 void set_delegate_for_testing(Delegate* delegate) { delegate_ = delegate; }
55 controller_ = c;
56 }
57 66
58 protected: 67 protected:
59 ResourceThrottle() : controller_(nullptr) {} 68 ResourceThrottle() : delegate_(nullptr) {}
60 ResourceController* controller() { return controller_; } 69
70 void Cancel();
jochen (gone - plz use gerrit) 2016/12/05 15:25:03 please add comments here as well
tyoshino (SeeGerritForStatus) 2016/12/06 11:25:31 Done.
71 void CancelAndIgnore();
72 void CancelWithError(int error_code);
73 void Resume();
61 74
62 private: 75 private:
63 friend class AsyncRevalidationDriver; 76 friend class AsyncRevalidationDriver;
64 friend class ThrottlingResourceHandler; 77 friend class ThrottlingResourceHandler;
65 void set_controller(ResourceController* c) { controller_ = c; } 78 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
66 79
67 ResourceController* controller_; 80 Delegate* delegate_;
68 }; 81 };
69 82
70 } // namespace content 83 } // namespace content
71 84
72 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_ 85 #endif // CONTENT_PUBLIC_BROWSER_RESOURCE_THROTTLE_H_
OLDNEW
« 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