| 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" |
| 6 #include "base/single_thread_task_runner.h" |
| 7 #include "base/thread_task_runner_handle.h" |
| 5 #include "chrome/common/local_discovery/service_discovery_client_impl.h" | 8 #include "chrome/common/local_discovery/service_discovery_client_impl.h" |
| 6 #include "net/dns/mdns_client_impl.h" | 9 #include "net/dns/mdns_client_impl.h" |
| 7 #include "net/dns/mock_mdns_socket_factory.h" | 10 #include "net/dns/mock_mdns_socket_factory.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 13 |
| 11 using ::testing::_; | 14 using ::testing::_; |
| 12 | 15 |
| 13 namespace local_discovery { | 16 namespace local_discovery { |
| 14 | 17 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const net::IPAddressNumber& address_ipv6) { | 77 const net::IPAddressNumber& address_ipv6) { |
| 75 AddressCallbackInternal(resolved, | 78 AddressCallbackInternal(resolved, |
| 76 IPAddressToStringWithEmpty(address_ipv4), | 79 IPAddressToStringWithEmpty(address_ipv4), |
| 77 IPAddressToStringWithEmpty(address_ipv6)); | 80 IPAddressToStringWithEmpty(address_ipv6)); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void RunFor(base::TimeDelta time_period) { | 83 void RunFor(base::TimeDelta time_period) { |
| 81 base::CancelableCallback<void()> callback(base::Bind( | 84 base::CancelableCallback<void()> callback(base::Bind( |
| 82 &base::MessageLoop::Quit, | 85 &base::MessageLoop::Quit, |
| 83 base::Unretained(base::MessageLoop::current()))); | 86 base::Unretained(base::MessageLoop::current()))); |
| 84 base::MessageLoop::current()->PostDelayedTask( | 87 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 85 FROM_HERE, callback.callback(), time_period); | 88 FROM_HERE, callback.callback(), time_period); |
| 86 | 89 |
| 87 base::MessageLoop::current()->Run(); | 90 base::MessageLoop::current()->Run(); |
| 88 callback.Cancel(); | 91 callback.Cancel(); |
| 89 } | 92 } |
| 90 | 93 |
| 91 MOCK_METHOD3(AddressCallbackInternal, | 94 MOCK_METHOD3(AddressCallbackInternal, |
| 92 void(bool resolved, | 95 void(bool resolved, |
| 93 std::string address_ipv4, | 96 std::string address_ipv4, |
| 94 std::string address_ipv6)); | 97 std::string address_ipv6)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 resolver.Start(); | 177 resolver.Start(); |
| 175 | 178 |
| 176 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); | 179 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); |
| 177 | 180 |
| 178 RunFor(base::TimeDelta::FromSeconds(4)); | 181 RunFor(base::TimeDelta::FromSeconds(4)); |
| 179 } | 182 } |
| 180 | 183 |
| 181 } // namespace | 184 } // namespace |
| 182 | 185 |
| 183 } // namespace local_discovery | 186 } // namespace local_discovery |
| OLD | NEW |