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

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

Issue 173049: Revert r23616 from 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
Reverse-merged /trunk/src/net/url_request/url_request_unittest.h:r14162,15308,16015,16808,19173,21417
Merged /trunk/src/net/url_request/url_request_unittest.h:r22067
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),
73 allow_certificate_errors_(false), 72 allow_certificate_errors_(false),
74 response_started_count_(0), 73 response_started_count_(0),
75 received_bytes_count_(0), 74 received_bytes_count_(0),
76 received_redirect_count_(0), 75 received_redirect_count_(0),
77 received_data_before_response_(false), 76 received_data_before_response_(false),
78 request_failed_(false), 77 request_failed_(false),
79 have_certificate_errors_(false), 78 have_certificate_errors_(false),
80 buf_(new net::IOBuffer(kBufferSize)) { 79 buf_(new net::IOBuffer(kBufferSize)) {
81 } 80 }
82 81
83 virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url, 82 virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url) {
84 bool* defer_redirect) {
85 received_redirect_count_++; 83 received_redirect_count_++;
86 if (quit_on_redirect_) { 84 if (cancel_in_rr_)
87 *defer_redirect = true;
88 MessageLoop::current()->Quit();
89 } else if (cancel_in_rr_) {
90 request->Cancel(); 85 request->Cancel();
91 }
92 } 86 }
93 87
94 virtual void OnResponseStarted(URLRequest* request) { 88 virtual void OnResponseStarted(URLRequest* request) {
95 // It doesn't make sense for the request to have IO pending at this point. 89 // It doesn't make sense for the request to have IO pending at this point.
96 DCHECK(!request->status().is_io_pending()); 90 DCHECK(!request->status().is_io_pending());
97 91
98 response_started_count_++; 92 response_started_count_++;
99 if (cancel_in_rs_) { 93 if (cancel_in_rs_) {
100 request->Cancel(); 94 request->Cancel();
101 OnResponseCompleted(request); 95 OnResponseCompleted(request);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 request->Cancel(); 170 request->Cancel();
177 } 171 }
178 172
179 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } 173 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; }
180 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; } 174 void set_cancel_in_response_started(bool val) { cancel_in_rs_ = val; }
181 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; } 175 void set_cancel_in_received_data(bool val) { cancel_in_rd_ = val; }
182 void set_cancel_in_received_data_pending(bool val) { 176 void set_cancel_in_received_data_pending(bool val) {
183 cancel_in_rd_pending_ = val; 177 cancel_in_rd_pending_ = val;
184 } 178 }
185 void set_quit_on_complete(bool val) { quit_on_complete_ = val; } 179 void set_quit_on_complete(bool val) { quit_on_complete_ = val; }
186 void set_quit_on_redirect(bool val) { quit_on_redirect_ = val; }
187 void set_allow_certificate_errors(bool val) { 180 void set_allow_certificate_errors(bool val) {
188 allow_certificate_errors_ = val; 181 allow_certificate_errors_ = val;
189 } 182 }
190 void set_username(const std::wstring& u) { username_ = u; } 183 void set_username(const std::wstring& u) { username_ = u; }
191 void set_password(const std::wstring& p) { password_ = p; } 184 void set_password(const std::wstring& p) { password_ = p; }
192 185
193 // query state 186 // query state
194 const std::string& data_received() const { return data_received_; } 187 const std::string& data_received() const { return data_received_; }
195 int bytes_received() const { return static_cast<int>(data_received_.size()); } 188 int bytes_received() const { return static_cast<int>(data_received_.size()); }
196 int response_started_count() const { return response_started_count_; } 189 int response_started_count() const { return response_started_count_; }
197 int received_redirect_count() const { return received_redirect_count_; } 190 int received_redirect_count() const { return received_redirect_count_; }
198 bool received_data_before_response() const { 191 bool received_data_before_response() const {
199 return received_data_before_response_; 192 return received_data_before_response_;
200 } 193 }
201 bool request_failed() const { return request_failed_; } 194 bool request_failed() const { return request_failed_; }
202 bool have_certificate_errors() const { return have_certificate_errors_; } 195 bool have_certificate_errors() const { return have_certificate_errors_; }
203 196
204 private: 197 private:
205 static const int kBufferSize = 4096; 198 static const int kBufferSize = 4096;
206 // options for controlling behavior 199 // options for controlling behavior
207 bool cancel_in_rr_; 200 bool cancel_in_rr_;
208 bool cancel_in_rs_; 201 bool cancel_in_rs_;
209 bool cancel_in_rd_; 202 bool cancel_in_rd_;
210 bool cancel_in_rd_pending_; 203 bool cancel_in_rd_pending_;
211 bool quit_on_complete_; 204 bool quit_on_complete_;
212 bool quit_on_redirect_;
213 bool allow_certificate_errors_; 205 bool allow_certificate_errors_;
214 206
215 std::wstring username_; 207 std::wstring username_;
216 std::wstring password_; 208 std::wstring password_;
217 209
218 // tracks status of callbacks 210 // tracks status of callbacks
219 int response_started_count_; 211 int response_started_count_;
220 int received_bytes_count_; 212 int received_bytes_count_;
221 int received_redirect_count_; 213 int received_redirect_count_;
222 bool received_data_before_response_; 214 bool received_data_before_response_;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 MessageLoop::current()->Run(); 545 MessageLoop::current()->Run();
554 if (request.is_pending()) 546 if (request.is_pending())
555 return false; 547 return false;
556 548
557 return true; 549 return true;
558 } 550 }
559 551
560 }; 552 };
561 553
562 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 554 #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