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

Side by Side Diff: chrome/common/net/url_fetcher_unittest.cc

Issue 6166010: net: Remove typedef net::URLRequestStatus URLRequestStatus; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/net/url_fetcher.cc ('k') | chrome/common/net/url_request_intercept_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/message_loop_proxy.h" 5 #include "base/message_loop_proxy.h"
6 #include "base/threading/thread.h" 6 #include "base/threading/thread.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/common/chrome_plugin_lib.h" 9 #include "chrome/common/chrome_plugin_lib.h"
10 #include "chrome/common/net/url_fetcher.h" 10 #include "chrome/common/net/url_fetcher.h"
11 #include "chrome/common/net/url_request_context_getter.h" 11 #include "chrome/common/net/url_request_context_getter.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 class URLFetcherTest : public testing::Test, public URLFetcher::Delegate { 55 class URLFetcherTest : public testing::Test, public URLFetcher::Delegate {
56 public: 56 public:
57 URLFetcherTest() : fetcher_(NULL) { } 57 URLFetcherTest() : fetcher_(NULL) { }
58 58
59 // Creates a URLFetcher, using the program's main thread to do IO. 59 // Creates a URLFetcher, using the program's main thread to do IO.
60 virtual void CreateFetcher(const GURL& url); 60 virtual void CreateFetcher(const GURL& url);
61 61
62 // URLFetcher::Delegate 62 // URLFetcher::Delegate
63 virtual void OnURLFetchComplete(const URLFetcher* source, 63 virtual void OnURLFetchComplete(const URLFetcher* source,
64 const GURL& url, 64 const GURL& url,
65 const URLRequestStatus& status, 65 const net::URLRequestStatus& status,
66 int response_code, 66 int response_code,
67 const ResponseCookies& cookies, 67 const ResponseCookies& cookies,
68 const std::string& data); 68 const std::string& data);
69 69
70 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() { 70 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy() {
71 return io_message_loop_proxy_; 71 return io_message_loop_proxy_;
72 } 72 }
73 73
74 protected: 74 protected:
75 virtual void SetUp() { 75 virtual void SetUp() {
(...skipping 25 matching lines...) Expand all
101 }; 101 };
102 102
103 // Version of URLFetcherTest that does a POST instead 103 // Version of URLFetcherTest that does a POST instead
104 class URLFetcherPostTest : public URLFetcherTest { 104 class URLFetcherPostTest : public URLFetcherTest {
105 public: 105 public:
106 virtual void CreateFetcher(const GURL& url); 106 virtual void CreateFetcher(const GURL& url);
107 107
108 // URLFetcher::Delegate 108 // URLFetcher::Delegate
109 virtual void OnURLFetchComplete(const URLFetcher* source, 109 virtual void OnURLFetchComplete(const URLFetcher* source,
110 const GURL& url, 110 const GURL& url,
111 const URLRequestStatus& status, 111 const net::URLRequestStatus& status,
112 int response_code, 112 int response_code,
113 const ResponseCookies& cookies, 113 const ResponseCookies& cookies,
114 const std::string& data); 114 const std::string& data);
115 }; 115 };
116 116
117 // Version of URLFetcherTest that tests headers. 117 // Version of URLFetcherTest that tests headers.
118 class URLFetcherHeadersTest : public URLFetcherTest { 118 class URLFetcherHeadersTest : public URLFetcherTest {
119 public: 119 public:
120 // URLFetcher::Delegate 120 // URLFetcher::Delegate
121 virtual void OnURLFetchComplete(const URLFetcher* source, 121 virtual void OnURLFetchComplete(const URLFetcher* source,
122 const GURL& url, 122 const GURL& url,
123 const URLRequestStatus& status, 123 const net::URLRequestStatus& status,
124 int response_code, 124 int response_code,
125 const ResponseCookies& cookies, 125 const ResponseCookies& cookies,
126 const std::string& data); 126 const std::string& data);
127 }; 127 };
128 128
129 // Version of URLFetcherTest that tests overload protection. 129 // Version of URLFetcherTest that tests overload protection.
130 class URLFetcherProtectTest : public URLFetcherTest { 130 class URLFetcherProtectTest : public URLFetcherTest {
131 public: 131 public:
132 virtual void CreateFetcher(const GURL& url); 132 virtual void CreateFetcher(const GURL& url);
133 // URLFetcher::Delegate 133 // URLFetcher::Delegate
134 virtual void OnURLFetchComplete(const URLFetcher* source, 134 virtual void OnURLFetchComplete(const URLFetcher* source,
135 const GURL& url, 135 const GURL& url,
136 const URLRequestStatus& status, 136 const net::URLRequestStatus& status,
137 int response_code, 137 int response_code,
138 const ResponseCookies& cookies, 138 const ResponseCookies& cookies,
139 const std::string& data); 139 const std::string& data);
140 private: 140 private:
141 Time start_time_; 141 Time start_time_;
142 }; 142 };
143 143
144 // Version of URLFetcherTest that tests overload protection, when responses 144 // Version of URLFetcherTest that tests overload protection, when responses
145 // passed through. 145 // passed through.
146 class URLFetcherProtectTestPassedThrough : public URLFetcherTest { 146 class URLFetcherProtectTestPassedThrough : public URLFetcherTest {
147 public: 147 public:
148 virtual void CreateFetcher(const GURL& url); 148 virtual void CreateFetcher(const GURL& url);
149 // URLFetcher::Delegate 149 // URLFetcher::Delegate
150 virtual void OnURLFetchComplete(const URLFetcher* source, 150 virtual void OnURLFetchComplete(const URLFetcher* source,
151 const GURL& url, 151 const GURL& url,
152 const URLRequestStatus& status, 152 const net::URLRequestStatus& status,
153 int response_code, 153 int response_code,
154 const ResponseCookies& cookies, 154 const ResponseCookies& cookies,
155 const std::string& data); 155 const std::string& data);
156 private: 156 private:
157 Time start_time_; 157 Time start_time_;
158 }; 158 };
159 159
160 // Version of URLFetcherTest that tests bad HTTPS requests. 160 // Version of URLFetcherTest that tests bad HTTPS requests.
161 class URLFetcherBadHTTPSTest : public URLFetcherTest { 161 class URLFetcherBadHTTPSTest : public URLFetcherTest {
162 public: 162 public:
163 URLFetcherBadHTTPSTest(); 163 URLFetcherBadHTTPSTest();
164 164
165 // URLFetcher::Delegate 165 // URLFetcher::Delegate
166 virtual void OnURLFetchComplete(const URLFetcher* source, 166 virtual void OnURLFetchComplete(const URLFetcher* source,
167 const GURL& url, 167 const GURL& url,
168 const URLRequestStatus& status, 168 const net::URLRequestStatus& status,
169 int response_code, 169 int response_code,
170 const ResponseCookies& cookies, 170 const ResponseCookies& cookies,
171 const std::string& data); 171 const std::string& data);
172 172
173 private: 173 private:
174 FilePath cert_dir_; 174 FilePath cert_dir_;
175 }; 175 };
176 176
177 // Version of URLFetcherTest that tests request cancellation on shutdown. 177 // Version of URLFetcherTest that tests request cancellation on shutdown.
178 class URLFetcherCancelTest : public URLFetcherTest { 178 class URLFetcherCancelTest : public URLFetcherTest {
179 public: 179 public:
180 virtual void CreateFetcher(const GURL& url); 180 virtual void CreateFetcher(const GURL& url);
181 // URLFetcher::Delegate 181 // URLFetcher::Delegate
182 virtual void OnURLFetchComplete(const URLFetcher* source, 182 virtual void OnURLFetchComplete(const URLFetcher* source,
183 const GURL& url, 183 const GURL& url,
184 const URLRequestStatus& status, 184 const net::URLRequestStatus& status,
185 int response_code, 185 int response_code,
186 const ResponseCookies& cookies, 186 const ResponseCookies& cookies,
187 const std::string& data); 187 const std::string& data);
188 188
189 void CancelRequest(); 189 void CancelRequest();
190 }; 190 };
191 191
192 // Version of TestURLRequestContext that posts a Quit task to the IO 192 // Version of TestURLRequestContext that posts a Quit task to the IO
193 // thread once it is deleted. 193 // thread once it is deleted.
194 class CancelTestURLRequestContext : public TestURLRequestContext { 194 class CancelTestURLRequestContext : public TestURLRequestContext {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 base::WaitableEvent context_created_; 227 base::WaitableEvent context_created_;
228 scoped_refptr<URLRequestContext> context_; 228 scoped_refptr<URLRequestContext> context_;
229 }; 229 };
230 230
231 // Version of URLFetcherTest that tests retying the same request twice. 231 // Version of URLFetcherTest that tests retying the same request twice.
232 class URLFetcherMultipleAttemptTest : public URLFetcherTest { 232 class URLFetcherMultipleAttemptTest : public URLFetcherTest {
233 public: 233 public:
234 // URLFetcher::Delegate 234 // URLFetcher::Delegate
235 virtual void OnURLFetchComplete(const URLFetcher* source, 235 virtual void OnURLFetchComplete(const URLFetcher* source,
236 const GURL& url, 236 const GURL& url,
237 const URLRequestStatus& status, 237 const net::URLRequestStatus& status,
238 int response_code, 238 int response_code,
239 const ResponseCookies& cookies, 239 const ResponseCookies& cookies,
240 const std::string& data); 240 const std::string& data);
241 private: 241 private:
242 std::string data_; 242 std::string data_;
243 }; 243 };
244 244
245 // Wrapper that lets us call CreateFetcher() on a thread of our choice. We 245 // Wrapper that lets us call CreateFetcher() on a thread of our choice. We
246 // could make URLFetcherTest refcounted and use PostTask(FROM_HERE.. ) to call 246 // could make URLFetcherTest refcounted and use PostTask(FROM_HERE.. ) to call
247 // CreateFetcher() directly, but the ownership of the URLFetcherTest is a bit 247 // CreateFetcher() directly, but the ownership of the URLFetcherTest is a bit
(...skipping 14 matching lines...) Expand all
262 262
263 void URLFetcherTest::CreateFetcher(const GURL& url) { 263 void URLFetcherTest::CreateFetcher(const GURL& url) {
264 fetcher_ = new URLFetcher(url, URLFetcher::GET, this); 264 fetcher_ = new URLFetcher(url, URLFetcher::GET, this);
265 fetcher_->set_request_context(new TestURLRequestContextGetter( 265 fetcher_->set_request_context(new TestURLRequestContextGetter(
266 io_message_loop_proxy())); 266 io_message_loop_proxy()));
267 fetcher_->Start(); 267 fetcher_->Start();
268 } 268 }
269 269
270 void URLFetcherTest::OnURLFetchComplete(const URLFetcher* source, 270 void URLFetcherTest::OnURLFetchComplete(const URLFetcher* source,
271 const GURL& url, 271 const GURL& url,
272 const URLRequestStatus& status, 272 const net::URLRequestStatus& status,
273 int response_code, 273 int response_code,
274 const ResponseCookies& cookies, 274 const ResponseCookies& cookies,
275 const std::string& data) { 275 const std::string& data) {
276 EXPECT_TRUE(status.is_success()); 276 EXPECT_TRUE(status.is_success());
277 EXPECT_EQ(200, response_code); // HTTP OK 277 EXPECT_EQ(200, response_code); // HTTP OK
278 EXPECT_FALSE(data.empty()); 278 EXPECT_FALSE(data.empty());
279 279
280 delete fetcher_; // Have to delete this here and not in the destructor, 280 delete fetcher_; // Have to delete this here and not in the destructor,
281 // because the destructor won't necessarily run on the 281 // because the destructor won't necessarily run on the
282 // same thread that CreateFetcher() did. 282 // same thread that CreateFetcher() did.
283 283
284 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 284 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
285 // If the current message loop is not the IO loop, it will be shut down when 285 // If the current message loop is not the IO loop, it will be shut down when
286 // the main loop returns and this thread subsequently goes out of scope. 286 // the main loop returns and this thread subsequently goes out of scope.
287 } 287 }
288 288
289 void URLFetcherPostTest::CreateFetcher(const GURL& url) { 289 void URLFetcherPostTest::CreateFetcher(const GURL& url) {
290 fetcher_ = new URLFetcher(url, URLFetcher::POST, this); 290 fetcher_ = new URLFetcher(url, URLFetcher::POST, this);
291 fetcher_->set_request_context(new TestURLRequestContextGetter( 291 fetcher_->set_request_context(new TestURLRequestContextGetter(
292 io_message_loop_proxy())); 292 io_message_loop_proxy()));
293 fetcher_->set_upload_data("application/x-www-form-urlencoded", 293 fetcher_->set_upload_data("application/x-www-form-urlencoded",
294 "bobsyeruncle"); 294 "bobsyeruncle");
295 fetcher_->Start(); 295 fetcher_->Start();
296 } 296 }
297 297
298 void URLFetcherPostTest::OnURLFetchComplete(const URLFetcher* source, 298 void URLFetcherPostTest::OnURLFetchComplete(const URLFetcher* source,
299 const GURL& url, 299 const GURL& url,
300 const URLRequestStatus& status, 300 const net::URLRequestStatus& status,
301 int response_code, 301 int response_code,
302 const ResponseCookies& cookies, 302 const ResponseCookies& cookies,
303 const std::string& data) { 303 const std::string& data) {
304 EXPECT_EQ(std::string("bobsyeruncle"), data); 304 EXPECT_EQ(std::string("bobsyeruncle"), data);
305 URLFetcherTest::OnURLFetchComplete(source, url, status, response_code, 305 URLFetcherTest::OnURLFetchComplete(source, url, status, response_code,
306 cookies, data); 306 cookies, data);
307 } 307 }
308 308
309 void URLFetcherHeadersTest::OnURLFetchComplete( 309 void URLFetcherHeadersTest::OnURLFetchComplete(
310 const URLFetcher* source, 310 const URLFetcher* source,
311 const GURL& url, 311 const GURL& url,
312 const URLRequestStatus& status, 312 const net::URLRequestStatus& status,
313 int response_code, 313 int response_code,
314 const ResponseCookies& cookies, 314 const ResponseCookies& cookies,
315 const std::string& data) { 315 const std::string& data) {
316 std::string header; 316 std::string header;
317 EXPECT_TRUE(source->response_headers()->GetNormalizedHeader("cache-control", 317 EXPECT_TRUE(source->response_headers()->GetNormalizedHeader("cache-control",
318 &header)); 318 &header));
319 EXPECT_EQ("private", header); 319 EXPECT_EQ("private", header);
320 URLFetcherTest::OnURLFetchComplete(source, url, status, response_code, 320 URLFetcherTest::OnURLFetchComplete(source, url, status, response_code,
321 cookies, data); 321 cookies, data);
322 } 322 }
323 323
324 void URLFetcherProtectTest::CreateFetcher(const GURL& url) { 324 void URLFetcherProtectTest::CreateFetcher(const GURL& url) {
325 fetcher_ = new URLFetcher(url, URLFetcher::GET, this); 325 fetcher_ = new URLFetcher(url, URLFetcher::GET, this);
326 fetcher_->set_request_context(new TestURLRequestContextGetter( 326 fetcher_->set_request_context(new TestURLRequestContextGetter(
327 io_message_loop_proxy())); 327 io_message_loop_proxy()));
328 start_time_ = Time::Now(); 328 start_time_ = Time::Now();
329 fetcher_->set_max_retries(11); 329 fetcher_->set_max_retries(11);
330 fetcher_->Start(); 330 fetcher_->Start();
331 } 331 }
332 332
333 void URLFetcherProtectTest::OnURLFetchComplete(const URLFetcher* source, 333 void URLFetcherProtectTest::OnURLFetchComplete(
334 const GURL& url, 334 const URLFetcher* source,
335 const URLRequestStatus& status, 335 const GURL& url,
336 int response_code, 336 const net::URLRequestStatus& status,
337 const ResponseCookies& cookies, 337 int response_code,
338 const std::string& data) { 338 const ResponseCookies& cookies,
339 const std::string& data) {
339 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000); 340 const TimeDelta one_second = TimeDelta::FromMilliseconds(1000);
340 if (response_code >= 500) { 341 if (response_code >= 500) {
341 // Now running ServerUnavailable test. 342 // Now running ServerUnavailable test.
342 // It takes more than 1 second to finish all 11 requests. 343 // It takes more than 1 second to finish all 11 requests.
343 EXPECT_TRUE(Time::Now() - start_time_ >= one_second); 344 EXPECT_TRUE(Time::Now() - start_time_ >= one_second);
344 EXPECT_TRUE(status.is_success()); 345 EXPECT_TRUE(status.is_success());
345 EXPECT_FALSE(data.empty()); 346 EXPECT_FALSE(data.empty());
346 delete fetcher_; 347 delete fetcher_;
347 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 348 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
348 } else { 349 } else {
(...skipping 18 matching lines...) Expand all
367 io_message_loop_proxy())); 368 io_message_loop_proxy()));
368 fetcher_->set_automatically_retry_on_5xx(false); 369 fetcher_->set_automatically_retry_on_5xx(false);
369 start_time_ = Time::Now(); 370 start_time_ = Time::Now();
370 fetcher_->set_max_retries(11); 371 fetcher_->set_max_retries(11);
371 fetcher_->Start(); 372 fetcher_->Start();
372 } 373 }
373 374
374 void URLFetcherProtectTestPassedThrough::OnURLFetchComplete( 375 void URLFetcherProtectTestPassedThrough::OnURLFetchComplete(
375 const URLFetcher* source, 376 const URLFetcher* source,
376 const GURL& url, 377 const GURL& url,
377 const URLRequestStatus& status, 378 const net::URLRequestStatus& status,
378 int response_code, 379 int response_code,
379 const ResponseCookies& cookies, 380 const ResponseCookies& cookies,
380 const std::string& data) { 381 const std::string& data) {
381 const TimeDelta one_minute = TimeDelta::FromMilliseconds(60000); 382 const TimeDelta one_minute = TimeDelta::FromMilliseconds(60000);
382 if (response_code >= 500) { 383 if (response_code >= 500) {
383 // Now running ServerUnavailable test. 384 // Now running ServerUnavailable test.
384 // It should get here on the first attempt, so almost immediately and 385 // It should get here on the first attempt, so almost immediately and
385 // *not* to attempt to execute all 11 requests (2.5 minutes). 386 // *not* to attempt to execute all 11 requests (2.5 minutes).
386 EXPECT_TRUE(Time::Now() - start_time_ < one_minute); 387 EXPECT_TRUE(Time::Now() - start_time_ < one_minute);
387 EXPECT_TRUE(status.is_success()); 388 EXPECT_TRUE(status.is_success());
(...skipping 18 matching lines...) Expand all
406 cert_dir_ = cert_dir_.AppendASCII("ssl"); 407 cert_dir_ = cert_dir_.AppendASCII("ssl");
407 cert_dir_ = cert_dir_.AppendASCII("certificates"); 408 cert_dir_ = cert_dir_.AppendASCII("certificates");
408 } 409 }
409 410
410 // The "server certificate expired" error should result in automatic 411 // The "server certificate expired" error should result in automatic
411 // cancellation of the request by 412 // cancellation of the request by
412 // net::URLRequest::Delegate::OnSSLCertificateError. 413 // net::URLRequest::Delegate::OnSSLCertificateError.
413 void URLFetcherBadHTTPSTest::OnURLFetchComplete( 414 void URLFetcherBadHTTPSTest::OnURLFetchComplete(
414 const URLFetcher* source, 415 const URLFetcher* source,
415 const GURL& url, 416 const GURL& url,
416 const URLRequestStatus& status, 417 const net::URLRequestStatus& status,
417 int response_code, 418 int response_code,
418 const ResponseCookies& cookies, 419 const ResponseCookies& cookies,
419 const std::string& data) { 420 const std::string& data) {
420 // This part is different from URLFetcherTest::OnURLFetchComplete 421 // This part is different from URLFetcherTest::OnURLFetchComplete
421 // because this test expects the request to be cancelled. 422 // because this test expects the request to be cancelled.
422 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); 423 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status());
423 EXPECT_EQ(net::ERR_ABORTED, status.os_error()); 424 EXPECT_EQ(net::ERR_ABORTED, status.os_error());
424 EXPECT_EQ(-1, response_code); 425 EXPECT_EQ(-1, response_code);
425 EXPECT_TRUE(cookies.empty()); 426 EXPECT_TRUE(cookies.empty());
426 EXPECT_TRUE(data.empty()); 427 EXPECT_TRUE(data.empty());
427 428
428 // The rest is the same as URLFetcherTest::OnURLFetchComplete. 429 // The rest is the same as URLFetcherTest::OnURLFetchComplete.
429 delete fetcher_; 430 delete fetcher_;
430 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 431 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
431 } 432 }
432 433
433 void URLFetcherCancelTest::CreateFetcher(const GURL& url) { 434 void URLFetcherCancelTest::CreateFetcher(const GURL& url) {
434 fetcher_ = new URLFetcher(url, URLFetcher::GET, this); 435 fetcher_ = new URLFetcher(url, URLFetcher::GET, this);
435 CancelTestURLRequestContextGetter* context_getter = 436 CancelTestURLRequestContextGetter* context_getter =
436 new CancelTestURLRequestContextGetter(io_message_loop_proxy()); 437 new CancelTestURLRequestContextGetter(io_message_loop_proxy());
437 fetcher_->set_request_context(context_getter); 438 fetcher_->set_request_context(context_getter);
438 fetcher_->set_max_retries(2); 439 fetcher_->set_max_retries(2);
439 fetcher_->Start(); 440 fetcher_->Start();
440 // We need to wait for the creation of the URLRequestContext, since we 441 // We need to wait for the creation of the URLRequestContext, since we
441 // rely on it being destroyed as a signal to end the test. 442 // rely on it being destroyed as a signal to end the test.
442 context_getter->WaitForContextCreation(); 443 context_getter->WaitForContextCreation();
443 CancelRequest(); 444 CancelRequest();
444 } 445 }
445 446
446 void URLFetcherCancelTest::OnURLFetchComplete(const URLFetcher* source, 447 void URLFetcherCancelTest::OnURLFetchComplete(
447 const GURL& url, 448 const URLFetcher* source,
448 const URLRequestStatus& status, 449 const GURL& url,
449 int response_code, 450 const net::URLRequestStatus& status,
450 const ResponseCookies& cookies, 451 int response_code,
451 const std::string& data) { 452 const ResponseCookies& cookies,
453 const std::string& data) {
452 // We should have cancelled the request before completion. 454 // We should have cancelled the request before completion.
453 ADD_FAILURE(); 455 ADD_FAILURE();
454 delete fetcher_; 456 delete fetcher_;
455 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 457 io_message_loop_proxy()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
456 } 458 }
457 459
458 void URLFetcherCancelTest::CancelRequest() { 460 void URLFetcherCancelTest::CancelRequest() {
459 delete fetcher_; 461 delete fetcher_;
460 // The URLFetcher's test context will post a Quit task once it is 462 // The URLFetcher's test context will post a Quit task once it is
461 // deleted. So if this test simply hangs, it means cancellation 463 // deleted. So if this test simply hangs, it means cancellation
462 // did not work. 464 // did not work.
463 } 465 }
464 466
465 void URLFetcherMultipleAttemptTest::OnURLFetchComplete( 467 void URLFetcherMultipleAttemptTest::OnURLFetchComplete(
466 const URLFetcher* source, 468 const URLFetcher* source,
467 const GURL& url, 469 const GURL& url,
468 const URLRequestStatus& status, 470 const net::URLRequestStatus& status,
469 int response_code, 471 int response_code,
470 const ResponseCookies& cookies, 472 const ResponseCookies& cookies,
471 const std::string& data) { 473 const std::string& data) {
472 EXPECT_TRUE(status.is_success()); 474 EXPECT_TRUE(status.is_success());
473 EXPECT_EQ(200, response_code); // HTTP OK 475 EXPECT_EQ(200, response_code); // HTTP OK
474 EXPECT_FALSE(data.empty()); 476 EXPECT_FALSE(data.empty());
475 if (!data.empty() && data_.empty()) { 477 if (!data.empty() && data_.empty()) {
476 data_ = data; 478 data_ = data;
477 fetcher_->Start(); 479 fetcher_->Start();
478 } else { 480 } else {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 676
675 // Create the fetcher on the main thread. Since IO will happen on the main 677 // Create the fetcher on the main thread. Since IO will happen on the main
676 // thread, this will test URLFetcher's ability to do everything on one 678 // thread, this will test URLFetcher's ability to do everything on one
677 // thread. 679 // thread.
678 CreateFetcher(test_server.GetURL("defaultresponse")); 680 CreateFetcher(test_server.GetURL("defaultresponse"));
679 681
680 MessageLoop::current()->Run(); 682 MessageLoop::current()->Run();
681 } 683 }
682 684
683 } // namespace. 685 } // namespace.
OLDNEW
« no previous file with comments | « chrome/common/net/url_fetcher.cc ('k') | chrome/common/net/url_request_intercept_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698