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

Side by Side Diff: net/dns/dns_config_service_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/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_transaction_unittest.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/dns/dns_config_service.h" 5 #include "net/dns/dns_config_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/cancelable_callback.h" 9 #include "base/cancelable_callback.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 EXPECT_EQ(kMixed, Classify("8.8.8.8 4.2.2.1")); 108 EXPECT_EQ(kMixed, Classify("8.8.8.8 4.2.2.1"));
109 EXPECT_EQ(kMixed, Classify("192.168.1.1 4.2.2.1")); 109 EXPECT_EQ(kMixed, Classify("192.168.1.1 4.2.2.1"));
110 EXPECT_EQ(kMixed, Classify("8.8.8.8 192.168.1.1 4.2.2.1")); 110 EXPECT_EQ(kMixed, Classify("8.8.8.8 192.168.1.1 4.2.2.1"));
111 } 111 }
112 112
113 class DnsConfigServiceTest : public testing::Test { 113 class DnsConfigServiceTest : public testing::Test {
114 public: 114 public:
115 void OnConfigChanged(const DnsConfig& config) { 115 void OnConfigChanged(const DnsConfig& config) {
116 last_config_ = config; 116 last_config_ = config;
117 if (quit_on_config_) 117 if (quit_on_config_)
118 base::MessageLoop::current()->Quit(); 118 base::MessageLoop::current()->QuitWhenIdle();
119 } 119 }
120 120
121 protected: 121 protected:
122 class TestDnsConfigService : public DnsConfigService { 122 class TestDnsConfigService : public DnsConfigService {
123 public: 123 public:
124 void ReadNow() override {} 124 void ReadNow() override {}
125 bool StartWatching() override { return true; } 125 bool StartWatching() override { return true; }
126 126
127 // Expose the protected methods to this test suite. 127 // Expose the protected methods to this test suite.
128 void InvalidateConfig() { 128 void InvalidateConfig() {
(...skipping 11 matching lines...) Expand all
140 void OnHostsRead(const DnsHosts& hosts) { 140 void OnHostsRead(const DnsHosts& hosts) {
141 DnsConfigService::OnHostsRead(hosts); 141 DnsConfigService::OnHostsRead(hosts);
142 } 142 }
143 143
144 void set_watch_failed(bool value) { 144 void set_watch_failed(bool value) {
145 DnsConfigService::set_watch_failed(value); 145 DnsConfigService::set_watch_failed(value);
146 } 146 }
147 }; 147 };
148 148
149 void WaitForConfig(base::TimeDelta timeout) { 149 void WaitForConfig(base::TimeDelta timeout) {
150 base::CancelableClosure closure(base::MessageLoop::QuitClosure()); 150 base::CancelableClosure closure(base::MessageLoop::QuitWhenIdleClosure());
151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
152 FROM_HERE, closure.callback(), timeout); 152 FROM_HERE, closure.callback(), timeout);
153 quit_on_config_ = true; 153 quit_on_config_ = true;
154 base::MessageLoop::current()->Run(); 154 base::MessageLoop::current()->Run();
155 quit_on_config_ = false; 155 quit_on_config_ = false;
156 closure.Cancel(); 156 closure.Cancel();
157 } 157 }
158 158
159 // Generate a config using the given seed.. 159 // Generate a config using the given seed..
160 DnsConfig MakeConfig(unsigned seed) { 160 DnsConfig MakeConfig(unsigned seed) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 last_config_ = bad_config; 328 last_config_ = bad_config;
329 // No change, so no update. 329 // No change, so no update.
330 service_->InvalidateConfig(); 330 service_->InvalidateConfig();
331 service_->OnConfigRead(config2); 331 service_->OnConfigRead(config2);
332 EXPECT_TRUE(last_config_.Equals(bad_config)); 332 EXPECT_TRUE(last_config_.Equals(bad_config));
333 } 333 }
334 334
335 } // namespace net 335 } // namespace net
336 336
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698