Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "jingle/glue/fake_network_manager.h" | 5 #include "jingle/glue/fake_network_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| 11 #include "jingle/glue/utils.h" | 11 #include "jingle/glue/utils.h" |
| 12 #include "third_party/libjingle/source/talk/base/socketaddress.h" | 12 #include "third_party/libjingle/source/talk/base/socketaddress.h" |
| 13 | 13 |
| 14 namespace jingle_glue { | 14 namespace jingle_glue { |
| 15 | 15 |
| 16 FakeNetworkManager::FakeNetworkManager(const net::IPAddressNumber& address) | 16 FakeNetworkManager::FakeNetworkManager(const net::IPAddressNumber& address) |
| 17 : started_(false), | 17 : started_(false), |
| 18 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 18 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 19 net::IPEndPoint endpoint(address, 0); | 19 net::IPEndPoint endpoint(address, 0); |
| 20 talk_base::SocketAddress socket_address; | 20 talk_base::SocketAddress socket_address; |
|
Wez
2012/03/09 22:51:52
nit: Can't we SocketAddress socket_address(IPAddre
Ronghua Wu (Left Chromium)
2012/03/09 23:28:47
Then we didn't use the input argument |address|, c
| |
| 21 CHECK(IPEndPointToSocketAddress(endpoint, &socket_address)); | 21 CHECK(IPEndPointToSocketAddress(endpoint, &socket_address)); |
| 22 network_.reset(new talk_base::Network("fake", "Fake Network", | 22 network_.reset(new talk_base::Network("fake", "Fake Network", |
| 23 socket_address.ipaddr())); | 23 socket_address.ipaddr(), 32)); |
| 24 network_->AddIP(socket_address.ipaddr()); | |
| 24 } | 25 } |
| 25 | 26 |
| 26 FakeNetworkManager::~FakeNetworkManager() { | 27 FakeNetworkManager::~FakeNetworkManager() { |
| 27 } | 28 } |
| 28 | 29 |
| 29 void FakeNetworkManager::StartUpdating() { | 30 void FakeNetworkManager::StartUpdating() { |
| 30 started_ = true; | 31 started_ = true; |
| 31 MessageLoop::current()->PostTask( | 32 MessageLoop::current()->PostTask( |
| 32 FROM_HERE, base::Bind(&FakeNetworkManager::SendNetworksChangedSignal, | 33 FROM_HERE, base::Bind(&FakeNetworkManager::SendNetworksChangedSignal, |
| 33 weak_factory_.GetWeakPtr())); | 34 weak_factory_.GetWeakPtr())); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void FakeNetworkManager::StopUpdating() { | 37 void FakeNetworkManager::StopUpdating() { |
| 37 started_ = false; | 38 started_ = false; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void FakeNetworkManager::GetNetworks(NetworkList* networks) const { | 41 void FakeNetworkManager::GetNetworks(NetworkList* networks) const { |
| 41 networks->clear(); | 42 networks->clear(); |
| 42 networks->push_back(network_.get()); | 43 networks->push_back(network_.get()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void FakeNetworkManager::SendNetworksChangedSignal() { | 46 void FakeNetworkManager::SendNetworksChangedSignal() { |
| 46 SignalNetworksChanged(); | 47 SignalNetworksChanged(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 } // namespace jingle_glue | 50 } // namespace jingle_glue |
| OLD | NEW |