OLD | NEW |
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 "net/test/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
10 #include "net/test/embedded_test_server/http_request.h" | 10 #include "net/test/embedded_test_server/http_request.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 virtual void ThreadMain() OVERRIDE { | 263 virtual void ThreadMain() OVERRIDE { |
264 scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner; | 264 scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner; |
265 base::Thread io_thread("io_thread"); | 265 base::Thread io_thread("io_thread"); |
266 base::Thread::Options thread_options; | 266 base::Thread::Options thread_options; |
267 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 267 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
268 ASSERT_TRUE(io_thread.StartWithOptions(thread_options)); | 268 ASSERT_TRUE(io_thread.StartWithOptions(thread_options)); |
269 io_thread_runner = io_thread.message_loop_proxy(); | 269 io_thread_runner = io_thread.message_loop_proxy(); |
270 | 270 |
271 scoped_ptr<base::MessageLoop> loop; | 271 scoped_ptr<base::MessageLoop> loop; |
272 if (message_loop_present_on_initialize_) | 272 if (message_loop_present_on_initialize_) |
273 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 273 loop.reset(new base::MessageLoopForIO); |
274 | 274 |
275 // Create the test server instance. | 275 // Create the test server instance. |
276 EmbeddedTestServer server; | 276 EmbeddedTestServer server; |
277 base::FilePath src_dir; | 277 base::FilePath src_dir; |
278 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); | 278 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)); |
279 ASSERT_TRUE(server.InitializeAndWaitUntilReady()); | 279 ASSERT_TRUE(server.InitializeAndWaitUntilReady()); |
280 | 280 |
281 // Make a request and wait for the reply. | 281 // Make a request and wait for the reply. |
282 if (!loop) | 282 if (!loop) |
283 loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 283 loop.reset(new base::MessageLoopForIO); |
284 | 284 |
285 scoped_ptr<URLFetcher> fetcher(URLFetcher::Create( | 285 scoped_ptr<URLFetcher> fetcher(URLFetcher::Create( |
286 server.GetURL("/test?q=foo"), URLFetcher::GET, this)); | 286 server.GetURL("/test?q=foo"), URLFetcher::GET, this)); |
287 fetcher->SetRequestContext( | 287 fetcher->SetRequestContext( |
288 new TestURLRequestContextGetter(loop->message_loop_proxy())); | 288 new TestURLRequestContextGetter(loop->message_loop_proxy())); |
289 fetcher->Start(); | 289 fetcher->Start(); |
290 loop->Run(); | 290 loop->Run(); |
291 fetcher.reset(); | 291 fetcher.reset(); |
292 | 292 |
293 // Shut down. | 293 // Shut down. |
(...skipping 26 matching lines...) Expand all Loading... |
320 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); | 320 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); |
321 base::PlatformThread::Join(thread_handle); | 321 base::PlatformThread::Join(thread_handle); |
322 } | 322 } |
323 | 323 |
324 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, | 324 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, |
325 EmbeddedTestServerThreadingTest, | 325 EmbeddedTestServerThreadingTest, |
326 testing::Combine(testing::Bool(), testing::Bool())); | 326 testing::Combine(testing::Bool(), testing::Bool())); |
327 | 327 |
328 } // namespace test_server | 328 } // namespace test_server |
329 } // namespace net | 329 } // namespace net |
OLD | NEW |