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

Side by Side Diff: content/common/net/url_fetcher_impl_unittest.cc

Issue 9572001: Do cookie checks in NetworkDelegate instead of the URLRequest::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 9 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 | « content/common/net/url_fetcher_impl.cc ('k') | content/common/net/url_request_user_data.h » ('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) 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 #include "content/common/net/url_fetcher_impl.h" 5 #include "content/common/net/url_fetcher_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 std::string data; 374 std::string data;
375 EXPECT_TRUE(source->GetResponseAsString(&data)); 375 EXPECT_TRUE(source->GetResponseAsString(&data));
376 EXPECT_FALSE(data.empty()); 376 EXPECT_FALSE(data.empty());
377 delete fetcher_; 377 delete fetcher_;
378 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 378 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
379 } else { 379 } else {
380 // Now running Overload test. 380 // Now running Overload test.
381 static int count = 0; 381 static int count = 0;
382 count++; 382 count++;
383 if (count < 20) { 383 if (count < 20) {
384 fetcher_->StartWithRequestContextGetter(new TestURLRequestContextGetter( 384 fetcher_->SetRequestContext(
385 io_message_loop_proxy())); 385 new TestURLRequestContextGetter(io_message_loop_proxy()));
386 fetcher_->Start();
386 } else { 387 } else {
387 // We have already sent 20 requests continuously. And we expect that 388 // We have already sent 20 requests continuously. And we expect that
388 // it takes more than 1 second due to the overload protection settings. 389 // it takes more than 1 second due to the overload protection settings.
389 EXPECT_TRUE(Time::Now() - start_time_ >= one_second); 390 EXPECT_TRUE(Time::Now() - start_time_ >= one_second);
390 URLFetcherTest::OnURLFetchComplete(source); 391 URLFetcherTest::OnURLFetchComplete(source);
391 } 392 }
392 } 393 }
393 } 394 }
394 395
395 void URLFetcherProtectTestPassedThrough::CreateFetcher(const GURL& url) { 396 void URLFetcherProtectTestPassedThrough::CreateFetcher(const GURL& url) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 486
486 void URLFetcherMultipleAttemptTest::OnURLFetchComplete( 487 void URLFetcherMultipleAttemptTest::OnURLFetchComplete(
487 const content::URLFetcher* source) { 488 const content::URLFetcher* source) {
488 EXPECT_TRUE(source->GetStatus().is_success()); 489 EXPECT_TRUE(source->GetStatus().is_success());
489 EXPECT_EQ(200, source->GetResponseCode()); // HTTP OK 490 EXPECT_EQ(200, source->GetResponseCode()); // HTTP OK
490 std::string data; 491 std::string data;
491 EXPECT_TRUE(source->GetResponseAsString(&data)); 492 EXPECT_TRUE(source->GetResponseAsString(&data));
492 EXPECT_FALSE(data.empty()); 493 EXPECT_FALSE(data.empty());
493 if (!data.empty() && data_.empty()) { 494 if (!data.empty() && data_.empty()) {
494 data_ = data; 495 data_ = data;
495 fetcher_->StartWithRequestContextGetter( 496 fetcher_->SetRequestContext(
496 new TestURLRequestContextGetter(io_message_loop_proxy())); 497 new TestURLRequestContextGetter(io_message_loop_proxy()));
498 fetcher_->Start();
497 } else { 499 } else {
498 EXPECT_EQ(data, data_); 500 EXPECT_EQ(data, data_);
499 delete fetcher_; // Have to delete this here and not in the destructor, 501 delete fetcher_; // Have to delete this here and not in the destructor,
500 // because the destructor won't necessarily run on the 502 // because the destructor won't necessarily run on the
501 // same thread that CreateFetcher() did. 503 // same thread that CreateFetcher() did.
502 504
503 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 505 io_message_loop_proxy()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
504 // If the current message loop is not the IO loop, it will be shut down when 506 // If the current message loop is not the IO loop, it will be shut down when
505 // the main loop returns and this thread subsequently goes out of scope. 507 // the main loop returns and this thread subsequently goes out of scope.
506 } 508 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 std::string(kTestServerFilePrefix) + kFileToFetch)); 898 std::string(kTestServerFilePrefix) + kFileToFetch));
897 899
898 MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). 900 MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
899 901
900 MessageLoop::current()->RunAllPending(); 902 MessageLoop::current()->RunAllPending();
901 ASSERT_FALSE(file_util::PathExists(temp_file_)) 903 ASSERT_FALSE(file_util::PathExists(temp_file_))
902 << temp_file_.value() << " not removed."; 904 << temp_file_.value() << " not removed.";
903 } 905 }
904 906
905 } // namespace. 907 } // namespace.
OLDNEW
« no previous file with comments | « content/common/net/url_fetcher_impl.cc ('k') | content/common/net/url_request_user_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698