OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location.h" |
5 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
6 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" |
7 #include "chrome/common/local_discovery/service_discovery_client_impl.h" | 10 #include "chrome/common/local_discovery/service_discovery_client_impl.h" |
8 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
9 #include "net/dns/dns_protocol.h" | 12 #include "net/dns/dns_protocol.h" |
10 #include "net/dns/mdns_client_impl.h" | 13 #include "net/dns/mdns_client_impl.h" |
11 #include "net/dns/mock_mdns_socket_factory.h" | 14 #include "net/dns/mock_mdns_socket_factory.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 | 17 |
15 using ::testing::_; | 18 using ::testing::_; |
16 using ::testing::Invoke; | 19 using ::testing::Invoke; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 : service_discovery_client_(&mdns_client_) { | 209 : service_discovery_client_(&mdns_client_) { |
207 mdns_client_.StartListening(&socket_factory_); | 210 mdns_client_.StartListening(&socket_factory_); |
208 } | 211 } |
209 | 212 |
210 ~ServiceDiscoveryTest() override {} | 213 ~ServiceDiscoveryTest() override {} |
211 | 214 |
212 protected: | 215 protected: |
213 void RunFor(base::TimeDelta time_period) { | 216 void RunFor(base::TimeDelta time_period) { |
214 base::CancelableCallback<void()> callback(base::Bind( | 217 base::CancelableCallback<void()> callback(base::Bind( |
215 &ServiceDiscoveryTest::Stop, base::Unretained(this))); | 218 &ServiceDiscoveryTest::Stop, base::Unretained(this))); |
216 base::MessageLoop::current()->PostDelayedTask( | 219 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
217 FROM_HERE, callback.callback(), time_period); | 220 FROM_HERE, callback.callback(), time_period); |
218 | 221 |
219 base::MessageLoop::current()->Run(); | 222 base::MessageLoop::current()->Run(); |
220 callback.Cancel(); | 223 callback.Cancel(); |
221 } | 224 } |
222 | 225 |
223 void Stop() { | 226 void Stop() { |
224 base::MessageLoop::current()->Quit(); | 227 base::MessageLoop::current()->Quit(); |
225 } | 228 } |
226 | 229 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 ServiceResolver::STATUS_REQUEST_TIMEOUT, _, _, _)); | 511 ServiceResolver::STATUS_REQUEST_TIMEOUT, _, _, _)); |
509 | 512 |
510 // TODO(noamsml): When NSEC record support is added, change this to use an | 513 // TODO(noamsml): When NSEC record support is added, change this to use an |
511 // NSEC record. | 514 // NSEC record. |
512 RunFor(base::TimeDelta::FromSeconds(4)); | 515 RunFor(base::TimeDelta::FromSeconds(4)); |
513 }; | 516 }; |
514 | 517 |
515 } // namespace | 518 } // namespace |
516 | 519 |
517 } // namespace local_discovery | 520 } // namespace local_discovery |
OLD | NEW |