| OLD | NEW |
| 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 #include "base/thread.h" | 5 #include "base/thread.h" |
| 6 #include "base/time.h" | 6 #include "base/time.h" |
| 7 #include "chrome/browser/net/url_fetcher.h" | 7 #include "chrome/browser/net/url_fetcher.h" |
| 8 #include "chrome/browser/net/url_fetcher_protect.h" | 8 #include "chrome/browser/net/url_fetcher_protect.h" |
| 9 #include "chrome/common/chrome_plugin_lib.h" | 9 #include "chrome/common/chrome_plugin_lib.h" |
| 10 #include "net/base/ssl_test_util.h" | 10 #include "net/base/ssl_test_util.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 timer_.Start(TimeDelta::FromMilliseconds(100), this, | 326 timer_.Start(TimeDelta::FromMilliseconds(100), this, |
| 327 &URLFetcherCancelTest::TestContextReleased); | 327 &URLFetcherCancelTest::TestContextReleased); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void URLFetcherCancelTest::TestContextReleased() { | 330 void URLFetcherCancelTest::TestContextReleased() { |
| 331 EXPECT_TRUE(context_released_); | 331 EXPECT_TRUE(context_released_); |
| 332 timer_.Stop(); | 332 timer_.Stop(); |
| 333 io_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 333 io_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace. | |
| 337 | |
| 338 TEST_F(URLFetcherTest, SameThreadsTest) { | 336 TEST_F(URLFetcherTest, SameThreadsTest) { |
| 339 // Create the fetcher on the main thread. Since IO will happen on the main | 337 // Create the fetcher on the main thread. Since IO will happen on the main |
| 340 // thread, this will test URLFetcher's ability to do everything on one | 338 // thread, this will test URLFetcher's ability to do everything on one |
| 341 // thread. | 339 // thread. |
| 342 scoped_refptr<HTTPTestServer> server = | 340 scoped_refptr<HTTPTestServer> server = |
| 343 HTTPTestServer::CreateServer(kDocRoot, NULL); | 341 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 344 ASSERT_TRUE(NULL != server.get()); | 342 ASSERT_TRUE(NULL != server.get()); |
| 345 | 343 |
| 346 CreateFetcher(GURL(server->TestServerPage("defaultresponse"))); | 344 CreateFetcher(GURL(server->TestServerPage("defaultresponse"))); |
| 347 | 345 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // (main) thread will do the IO, and when the fetch is complete it will | 453 // (main) thread will do the IO, and when the fetch is complete it will |
| 456 // terminate the main thread's message loop; then the other thread's | 454 // terminate the main thread's message loop; then the other thread's |
| 457 // message loop will be shut down automatically as the thread goes out of | 455 // message loop will be shut down automatically as the thread goes out of |
| 458 // scope. | 456 // scope. |
| 459 base::Thread t("URLFetcher test thread"); | 457 base::Thread t("URLFetcher test thread"); |
| 460 t.Start(); | 458 t.Start(); |
| 461 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); | 459 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); |
| 462 | 460 |
| 463 MessageLoop::current()->Run(); | 461 MessageLoop::current()->Run(); |
| 464 } | 462 } |
| 463 |
| 464 } // namespace. |
| OLD | NEW |