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
3 // found in the LICENSE file.
5 #include "jingle/glue/fake_network_manager.h"
8 #include "base/logging.h"
9 #include "base/message_loop.h"
10 #include "net/base/ip_endpoint.h"
11 #include "jingle/glue/utils.h"
12 #include "third_party/libjingle/source/talk/base/socketaddress.h"
14 namespace jingle_glue
{
16 FakeNetworkManager::FakeNetworkManager(const net::IPAddressNumber
& address
)
18 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
19 net::IPEndPoint
endpoint(address
, 0);
20 talk_base::SocketAddress socket_address
;
21 CHECK(IPEndPointToSocketAddress(endpoint
, &socket_address
));
22 network_
.reset(new talk_base::Network("fake", "Fake Network",
23 socket_address
.ipaddr(), 32));
24 network_
->AddIP(socket_address
.ipaddr());
27 FakeNetworkManager::~FakeNetworkManager() {
30 void FakeNetworkManager::StartUpdating() {
32 MessageLoop::current()->PostTask(
33 FROM_HERE
, base::Bind(&FakeNetworkManager::SendNetworksChangedSignal
,
34 weak_factory_
.GetWeakPtr()));
37 void FakeNetworkManager::StopUpdating() {
41 void FakeNetworkManager::GetNetworks(NetworkList
* networks
) const {
43 networks
->push_back(network_
.get());
46 void FakeNetworkManager::SendNetworksChangedSignal() {
47 SignalNetworksChanged();
50 } // namespace jingle_glue