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

Side by Side Diff: net/test/embedded_test_server/embedded_test_server_unittest.cc

Issue 1398973003: Don't use base::MessageLoop::{Quit,QuitClosure} in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/socket/ssl_server_socket_unittest.cc ('k') | net/tools/gdig/gdig.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) 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/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void TearDown() override { 126 void TearDown() override {
127 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete()); 127 ASSERT_TRUE(server_->ShutdownAndWaitUntilComplete());
128 } 128 }
129 129
130 // URLFetcherDelegate override. 130 // URLFetcherDelegate override.
131 void OnURLFetchComplete(const URLFetcher* source) override { 131 void OnURLFetchComplete(const URLFetcher* source) override {
132 ++num_responses_received_; 132 ++num_responses_received_;
133 if (num_responses_received_ == num_responses_expected_) 133 if (num_responses_received_ == num_responses_expected_)
134 base::MessageLoop::current()->Quit(); 134 base::MessageLoop::current()->QuitWhenIdle();
135 } 135 }
136 136
137 // Waits until the specified number of responses are received. 137 // Waits until the specified number of responses are received.
138 void WaitForResponses(int num_responses) { 138 void WaitForResponses(int num_responses) {
139 num_responses_received_ = 0; 139 num_responses_received_ = 0;
140 num_responses_expected_ = num_responses; 140 num_responses_expected_ = num_responses;
141 // Will be terminated in OnURLFetchComplete(). 141 // Will be terminated in OnURLFetchComplete().
142 base::MessageLoop::current()->Run(); 142 base::MessageLoop::current()->Run();
143 } 143 }
144 144
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 // Shut down. 378 // Shut down.
379 if (message_loop_present_on_shutdown_) 379 if (message_loop_present_on_shutdown_)
380 loop.reset(); 380 loop.reset();
381 381
382 ASSERT_TRUE(server.ShutdownAndWaitUntilComplete()); 382 ASSERT_TRUE(server.ShutdownAndWaitUntilComplete());
383 } 383 }
384 384
385 // URLFetcherDelegate override. 385 // URLFetcherDelegate override.
386 void OnURLFetchComplete(const URLFetcher* source) override { 386 void OnURLFetchComplete(const URLFetcher* source) override {
387 base::MessageLoop::current()->Quit(); 387 base::MessageLoop::current()->QuitWhenIdle();
388 } 388 }
389 389
390 private: 390 private:
391 bool message_loop_present_on_initialize_; 391 bool message_loop_present_on_initialize_;
392 bool message_loop_present_on_shutdown_; 392 bool message_loop_present_on_shutdown_;
393 393
394 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServerThreadingTestDelegate); 394 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServerThreadingTestDelegate);
395 }; 395 };
396 396
397 TEST_P(EmbeddedTestServerThreadingTest, RunTest) { 397 TEST_P(EmbeddedTestServerThreadingTest, RunTest) {
398 // The actual test runs on a separate thread so it can screw with the presence 398 // The actual test runs on a separate thread so it can screw with the presence
399 // of a MessageLoop - the test suite already sets up a MessageLoop for the 399 // of a MessageLoop - the test suite already sets up a MessageLoop for the
400 // main test thread. 400 // main test thread.
401 base::PlatformThreadHandle thread_handle; 401 base::PlatformThreadHandle thread_handle;
402 EmbeddedTestServerThreadingTestDelegate delegate( 402 EmbeddedTestServerThreadingTestDelegate delegate(
403 std::tr1::get<0>(GetParam()), 403 std::tr1::get<0>(GetParam()),
404 std::tr1::get<1>(GetParam())); 404 std::tr1::get<1>(GetParam()));
405 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); 405 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle));
406 base::PlatformThread::Join(thread_handle); 406 base::PlatformThread::Join(thread_handle);
407 } 407 }
408 408
409 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, 409 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation,
410 EmbeddedTestServerThreadingTest, 410 EmbeddedTestServerThreadingTest,
411 testing::Combine(testing::Bool(), testing::Bool())); 411 testing::Combine(testing::Bool(), testing::Bool()));
412 412
413 } // namespace test_server 413 } // namespace test_server
414 } // namespace net 414 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_unittest.cc ('k') | net/tools/gdig/gdig.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698