OLD | NEW |
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_RESOURCE_LOADER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // otherwise. | 92 // otherwise. |
93 void Resume(bool called_from_resource_controller); | 93 void Resume(bool called_from_resource_controller); |
94 void Cancel(); | 94 void Cancel(); |
95 void CancelAndIgnore(); | 95 void CancelAndIgnore(); |
96 void CancelWithError(int error_code); | 96 void CancelWithError(int error_code); |
97 | 97 |
98 void StartRequestInternal(); | 98 void StartRequestInternal(); |
99 void CancelRequestInternal(int error, bool from_renderer); | 99 void CancelRequestInternal(int error, bool from_renderer); |
100 void FollowDeferredRedirectInternal(); | 100 void FollowDeferredRedirectInternal(); |
101 void CompleteResponseStarted(); | 101 void CompleteResponseStarted(); |
102 // If |handle_result_async| is true, the result of a read that completed | 102 // If |handle_result_async| is true, the result of the following read will be |
103 // synchronously will be handled asynchronously, except on EOF or error. | 103 // handled asynchronously if it completes synchronously, unless it's EOF or an |
| 104 // error. This is to prevent a single request from blocking the thread for too |
| 105 // long. |
| 106 void PrepareToReadMore(bool handle_result_async); |
104 void ReadMore(bool handle_result_async); | 107 void ReadMore(bool handle_result_async); |
105 void ResumeReading(); | 108 void ResumeReading(); |
106 // Passes a read result to the handler. | 109 // Passes a read result to the handler. |
107 void CompleteRead(int bytes_read); | 110 void CompleteRead(int bytes_read); |
108 void ResponseCompleted(); | 111 void ResponseCompleted(); |
109 void CallDidFinishLoading(); | 112 void CallDidFinishLoading(); |
110 void RecordHistograms(); | 113 void RecordHistograms(); |
111 | 114 |
112 bool is_deferred() const { return deferred_stage_ != DEFERRED_NONE; } | 115 bool is_deferred() const { return deferred_stage_ != DEFERRED_NONE; } |
113 | 116 |
(...skipping 12 matching lines...) Expand all Loading... |
126 enum DeferredStage { | 129 enum DeferredStage { |
127 DEFERRED_NONE, | 130 DEFERRED_NONE, |
128 // Magic deferral "stage" which means that the code is currently in a | 131 // Magic deferral "stage" which means that the code is currently in a |
129 // recursive call from the ResourceLoader. When in this state, Resume() does | 132 // recursive call from the ResourceLoader. When in this state, Resume() does |
130 // nothing but update the deferral state, and when the stack is unwound back | 133 // nothing but update the deferral state, and when the stack is unwound back |
131 // up to the ResourceLoader, the request will be continued. This is used to | 134 // up to the ResourceLoader, the request will be continued. This is used to |
132 // prevent the stack from getting too deep. | 135 // prevent the stack from getting too deep. |
133 DEFERRED_SYNC, | 136 DEFERRED_SYNC, |
134 DEFERRED_START, | 137 DEFERRED_START, |
135 DEFERRED_REDIRECT, | 138 DEFERRED_REDIRECT, |
| 139 DEFERRED_ON_WILL_READ, |
136 DEFERRED_READ, | 140 DEFERRED_READ, |
137 DEFERRED_RESPONSE_COMPLETE, | 141 DEFERRED_RESPONSE_COMPLETE, |
138 DEFERRED_FINISH | 142 DEFERRED_FINISH |
139 }; | 143 }; |
140 DeferredStage deferred_stage_; | 144 DeferredStage deferred_stage_; |
141 | 145 |
142 class ScopedDeferral; | 146 class ScopedDeferral; |
143 | 147 |
144 std::unique_ptr<net::URLRequest> request_; | 148 std::unique_ptr<net::URLRequest> request_; |
145 std::unique_ptr<ResourceHandler> handler_; | 149 std::unique_ptr<ResourceHandler> handler_; |
(...skipping 14 matching lines...) Expand all Loading... |
160 | 164 |
161 // Instrumentation add to investigate http://crbug.com/503306. | 165 // Instrumentation add to investigate http://crbug.com/503306. |
162 // TODO(mmenke): Remove once bug is fixed. | 166 // TODO(mmenke): Remove once bug is fixed. |
163 int times_cancelled_before_request_start_; | 167 int times_cancelled_before_request_start_; |
164 bool started_request_; | 168 bool started_request_; |
165 int times_cancelled_after_request_start_; | 169 int times_cancelled_after_request_start_; |
166 | 170 |
167 // Stores the URL from a deferred redirect. | 171 // Stores the URL from a deferred redirect. |
168 GURL deferred_redirect_url_; | 172 GURL deferred_redirect_url_; |
169 | 173 |
| 174 // Read buffer and its size. Class members as OnWillRead can complete |
| 175 // asynchronously. |
| 176 scoped_refptr<net::IOBuffer> read_buffer_; |
| 177 int read_buffer_size_; |
| 178 |
170 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; | 179 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; |
171 | 180 |
172 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 181 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
173 }; | 182 }; |
174 | 183 |
175 } // namespace content | 184 } // namespace content |
176 | 185 |
177 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 186 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
OLD | NEW |