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

Side by Side Diff: net/url_request/url_request_unittest.h

Issue 171099: Merge r21417 to 172.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: '' Created 11 years, 4 months 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
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/net/url_request/url_request_unittest.h:r14162,15308,16015,16808,19173,21417
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <sstream> 10 #include <sstream>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 }; 62 };
63 63
64 class TestDelegate : public URLRequest::Delegate { 64 class TestDelegate : public URLRequest::Delegate {
65 public: 65 public:
66 TestDelegate() 66 TestDelegate()
67 : cancel_in_rr_(false), 67 : cancel_in_rr_(false),
68 cancel_in_rs_(false), 68 cancel_in_rs_(false),
69 cancel_in_rd_(false), 69 cancel_in_rd_(false),
70 cancel_in_rd_pending_(false), 70 cancel_in_rd_pending_(false),
71 quit_on_complete_(true), 71 quit_on_complete_(true),
72 quit_on_redirect_(false),
72 allow_certificate_errors_(false), 73 allow_certificate_errors_(false),
73 response_started_count_(0), 74 response_started_count_(0),
74 received_bytes_count_(0), 75 received_bytes_count_(0),
75 received_redirect_count_(0), 76 received_redirect_count_(0),
76 received_data_before_response_(false), 77 received_data_before_response_(false),
77 request_failed_(false), 78 request_failed_(false),
78 have_certificate_errors_(false), 79 have_certificate_errors_(false),
79 buf_(new net::IOBuffer(kBufferSize)) { 80 buf_(new net::IOBuffer(kBufferSize)) {
80 } 81 }
81 82
82 virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url) { 83 virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url,
84 bool* defer_redirect) {
83 received_redirect_count_++; 85 received_redirect_count_++;
84 if (cancel_in_rr_) 86 if (quit_on_redirect_) {
87 *defer_redirect = true;
88 MessageLoop::current()->Quit();
89 } else if (cancel_in_rr_) {
85 request->Cancel(); 90 request->Cancel();
91 }
86 } 92 }
87 93
88 virtual void OnResponseStarted(URLRequest* request) { 94 virtual void OnResponseStarted(URLRequest* request) {
89 // It doesn't make sense for the request to have IO pending at this point. 95 // It doesn't make sense for the request to have IO pending at this point.
90 DCHECK(!request->status().is_io_pending()); 96 DCHECK(!request->status().is_io_pending());
91 97
92 response_started_count_++; 98 response_started_count_++;
93 if (cancel_in_rs_) { 99 if (cancel_in_rs_) {
94 request->Cancel(); 100 request->Cancel();
95 OnResponseCompleted(request); 101 OnResponseCompleted(request);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 request->Cancel(); 176 request->Cancel();
171 } 177 }
172 178
173 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } 179 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; }
174 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; } 180 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; }
175 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; } 181 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; }
176 void set_cancel_in_received_data_pending(bool val) { 182 void set_cancel_in_received_data_pending(bool val) {
177 cancel_in_rd_pending_ = val; 183 cancel_in_rd_pending_ = val;
178 } 184 }
179 void set_quit_on_complete(bool val) { quit_on_complete_ = val; } 185 void set_quit_on_complete(bool val) { quit_on_complete_ = val; }
186 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; }
180 void set_allow_certificate_errors(bool val) { 187 void set_allow_certificate_errors(bool val) {
181 allow_certificate_errors_ = val; 188 allow_certificate_errors_ = val;
182 } 189 }
183 void set_username(const std::wstring& u) { username_ = u; } 190 void set_username(const std::wstring& u) { username_ = u; }
184 void set_password(const std::wstring& p) { password_ = p; } 191 void set_password(const std::wstring& p) { password_ = p; }
185 192
186 // query state 193 // query state
187 const std::string& data_received() const { return data_received_; } 194 const std::string& data_received() const { return data_received_; }
188 int bytes_received() const { return static_cast<int>(data_received_.size()); } 195 int bytes_received() const { return static_cast<int>(data_received_.size()); }
189 int response_started_count() const { return response_started_count_; } 196 int response_started_count() const { return response_started_count_; }
190 int received_redirect_count() const { return received_redirect_count_; } 197 int received_redirect_count() const { return received_redirect_count_; }
191 bool received_data_before_response() const { 198 bool received_data_before_response() const {
192 return received_data_before_response_; 199 return received_data_before_response_;
193 } 200 }
194 bool request_failed() const { return request_failed_; } 201 bool request_failed() const { return request_failed_; }
195 bool have_certificate_errors() const { return have_certificate_errors_; } 202 bool have_certificate_errors() const { return have_certificate_errors_; }
196 203
197 private: 204 private:
198 static const int kBufferSize = 4096; 205 static const int kBufferSize = 4096;
199 // options for controlling behavior 206 // options for controlling behavior
200 bool cancel_in_rr_; 207 bool cancel_in_rr_;
201 bool cancel_in_rs_; 208 bool cancel_in_rs_;
202 bool cancel_in_rd_; 209 bool cancel_in_rd_;
203 bool cancel_in_rd_pending_; 210 bool cancel_in_rd_pending_;
204 bool quit_on_complete_; 211 bool quit_on_complete_;
212 bool quit_on_redirect_;
205 bool allow_certificate_errors_; 213 bool allow_certificate_errors_;
206 214
207 std::wstring username_; 215 std::wstring username_;
208 std::wstring password_; 216 std::wstring password_;
209 217
210 // tracks status of callbacks 218 // tracks status of callbacks
211 int response_started_count_; 219 int response_started_count_;
212 int received_bytes_count_; 220 int received_bytes_count_;
213 int received_redirect_count_; 221 int received_redirect_count_;
214 bool received_data_before_response_; 222 bool received_data_before_response_;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 MessageLoop::current()->Run(); 553 MessageLoop::current()->Run();
546 if (request.is_pending()) 554 if (request.is_pending())
547 return false; 555 return false;
548 556
549 return true; 557 return true;
550 } 558 }
551 559
552 }; 560 };
553 561
554 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 562 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698