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

Side by Side Diff: content/browser/loader/throttling_resource_handler.h

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Fix merge again (?) 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_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
13 #include "content/browser/loader/layered_resource_handler.h" 15 #include "content/browser/loader/layered_resource_handler.h"
14 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
15 #include "content/public/browser/resource_throttle.h" 17 #include "content/public/browser/resource_throttle.h"
16 #include "net/url_request/redirect_info.h" 18 #include "net/url_request/redirect_info.h"
17 #include "url/gurl.h" 19 #include "url/gurl.h"
18 20
19 namespace net { 21 namespace net {
20 class URLRequest; 22 class URLRequest;
21 } 23 }
22 24
23 namespace content { 25 namespace content {
24 26
25 struct ResourceResponse; 27 struct ResourceResponse;
26 28
27 // Used to apply a list of ResourceThrottle instances to an URLRequest. 29 // Used to apply a list of ResourceThrottle instances to an URLRequest.
28 class CONTENT_EXPORT ThrottlingResourceHandler 30 class CONTENT_EXPORT ThrottlingResourceHandler
29 : public LayeredResourceHandler, 31 : public LayeredResourceHandler,
30 public ResourceThrottle::Delegate { 32 public ResourceThrottle::Delegate {
31 public: 33 public:
32 // Takes ownership of the ResourceThrottle instances. 34 // Takes ownership of the ResourceThrottle instances.
33 ThrottlingResourceHandler(std::unique_ptr<ResourceHandler> next_handler, 35 ThrottlingResourceHandler(std::unique_ptr<ResourceHandler> next_handler,
34 net::URLRequest* request, 36 net::URLRequest* request,
35 ScopedVector<ResourceThrottle> throttles); 37 ScopedVector<ResourceThrottle> throttles);
36 ~ThrottlingResourceHandler() override; 38 ~ThrottlingResourceHandler() override;
37 39
38 // LayeredResourceHandler overrides: 40 // LayeredResourceHandler overrides:
39 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 41 void OnRequestRedirected(
40 ResourceResponse* response, 42 const net::RedirectInfo& redirect_info,
41 bool* defer) override; 43 ResourceResponse* response,
42 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 44 std::unique_ptr<ResourceController> controller) override;
43 bool OnWillStart(const GURL& url, bool* defer) override; 45 void OnResponseStarted(
46 ResourceResponse* response,
47 std::unique_ptr<ResourceController> controller) override;
48 void OnWillStart(const GURL& url,
49 std::unique_ptr<ResourceController> controller) override;
44 50
45 // ResourceThrottle::Delegate implementation: 51 // ResourceThrottle::Delegate implementation:
46 void Cancel() override; 52 void Cancel() override;
47 void CancelAndIgnore() override; 53 void CancelAndIgnore() override;
48 void CancelWithError(int error_code) override; 54 void CancelWithError(int error_code) override;
49 void Resume() override; 55 void Resume() override;
50 56
51 private: 57 private:
52 void ResumeStart(); 58 void ResumeStart();
53 void ResumeRedirect(); 59 void ResumeRedirect();
(...skipping 19 matching lines...) Expand all
73 scoped_refptr<ResourceResponse> deferred_response_; 79 scoped_refptr<ResourceResponse> deferred_response_;
74 80
75 bool cancelled_by_resource_throttle_; 81 bool cancelled_by_resource_throttle_;
76 82
77 DISALLOW_COPY_AND_ASSIGN(ThrottlingResourceHandler); 83 DISALLOW_COPY_AND_ASSIGN(ThrottlingResourceHandler);
78 }; 84 };
79 85
80 } // namespace content 86 } // namespace content
81 87
82 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ 88 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698