OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ |
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/public/browser/resource_request_info.h" |
13 #include "content/public/browser/resource_throttle.h" | 14 #include "content/public/browser/resource_throttle.h" |
14 #include "content/public/common/resource_type.h" | 15 #include "content/public/common/resource_type.h" |
15 | 16 |
16 class GURL; | 17 class GURL; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 class URLRequest; | 20 class URLRequest; |
20 } | 21 } |
21 | 22 |
22 namespace prerender { | 23 namespace prerender { |
(...skipping 25 matching lines...) Expand all Loading... |
48 // May only be called if currently throttling the resource. | 49 // May only be called if currently throttling the resource. |
49 void ResumeHandler(); | 50 void ResumeHandler(); |
50 | 51 |
51 static void OverridePrerenderContentsForTesting(PrerenderContents* contents); | 52 static void OverridePrerenderContentsForTesting(PrerenderContents* contents); |
52 | 53 |
53 private: | 54 private: |
54 static void WillStartRequestOnUI( | 55 static void WillStartRequestOnUI( |
55 const base::WeakPtr<PrerenderResourceThrottle>& throttle, | 56 const base::WeakPtr<PrerenderResourceThrottle>& throttle, |
56 const std::string& method, | 57 const std::string& method, |
57 content::ResourceType resource_type, | 58 content::ResourceType resource_type, |
58 int render_process_id, | |
59 int render_frame_id, | |
60 const GURL& url, | 59 const GURL& url, |
| 60 const content::ResourceRequestInfo::WebContentsGetter& |
| 61 web_contents_getter, |
61 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info); | 62 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info); |
62 | 63 |
63 static void WillRedirectRequestOnUI( | 64 static void WillRedirectRequestOnUI( |
64 const base::WeakPtr<PrerenderResourceThrottle>& throttle, | 65 const base::WeakPtr<PrerenderResourceThrottle>& throttle, |
65 const std::string& follow_only_when_prerender_shown_header, | 66 const std::string& follow_only_when_prerender_shown_header, |
66 content::ResourceType resource_type, | 67 content::ResourceType resource_type, |
67 bool async, | 68 bool async, |
68 bool is_no_store, | 69 bool is_no_store, |
69 int render_process_id, | 70 const GURL& new_url, |
70 int render_frame_id, | 71 const content::ResourceRequestInfo::WebContentsGetter& |
71 const GURL& new_url); | 72 web_contents_getter); |
72 | 73 |
73 static void WillProcessResponseOnUI( | 74 static void WillProcessResponseOnUI( |
74 bool is_main_resource, | 75 bool is_main_resource, |
75 bool is_no_store, | 76 bool is_no_store, |
76 int redirect_count, | 77 int redirect_count, |
77 int render_process_id, | |
78 int render_frame_id, | |
79 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info); | 78 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info); |
80 | 79 |
81 // Helper to return the PrerenderContents given a render frame id. May return | 80 // Helper to return the PrerenderContents given a WebContentsGetter. May |
82 // NULL if it's gone. | 81 // return nullptr if it's gone. |
83 static PrerenderContents* PrerenderContentsFromRenderFrame( | 82 static PrerenderContents* PrerenderContentsFromGetter( |
84 int render_process_id, int render_frame_id); | 83 const content::ResourceRequestInfo::WebContentsGetter& |
| 84 web_contents_getter); |
85 | 85 |
86 net::URLRequest* request_; | 86 net::URLRequest* request_; |
87 | 87 |
88 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info_; | 88 scoped_refptr<PrerenderThrottleInfo> prerender_throttle_info_; |
89 | 89 |
90 DISALLOW_COPY_AND_ASSIGN(PrerenderResourceThrottle); | 90 DISALLOW_COPY_AND_ASSIGN(PrerenderResourceThrottle); |
91 }; | 91 }; |
92 | 92 |
93 } // namespace prerender | 93 } // namespace prerender |
94 | 94 |
95 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ | 95 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_RESOURCE_THROTTLE_H_ |
OLD | NEW |