diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 18:20:44 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-13 18:20:44 +0000 |
commit | 6d802c63cdc5c992b2ff8323b1c2ab3fc6fb5083 (patch) | |
tree | 87626201e260942d89f46e79d8811d38cce26def /jingle | |
parent | 436fd41df6378a81cbd8706eb9b1daed95cc7cab (diff) | |
download | chromium_src-6d802c63cdc5c992b2ff8323b1c2ab3fc6fb5083.zip chromium_src-6d802c63cdc5c992b2ff8323b1c2ab3fc6fb5083.tar.gz chromium_src-6d802c63cdc5c992b2ff8323b1c2ab3fc6fb5083.tar.bz2 |
Roll new libjingle with asynchronous NetworkManager.
BUG=84243
TEST=Unittests
Review URL: http://codereview.chromium.org/7338003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/glue/fake_network_manager.cc | 35 | ||||
-rw-r--r-- | jingle/glue/fake_network_manager.h | 17 |
2 files changed, 38 insertions, 14 deletions
diff --git a/jingle/glue/fake_network_manager.cc b/jingle/glue/fake_network_manager.cc index f37208d..26c2fd0 100644 --- a/jingle/glue/fake_network_manager.cc +++ b/jingle/glue/fake_network_manager.cc @@ -5,6 +5,7 @@ #include "jingle/glue/fake_network_manager.h" #include "base/logging.h" +#include "base/message_loop.h" #include "net/base/ip_endpoint.h" #include "jingle/glue/utils.h" #include "third_party/libjingle/source/talk/base/socketaddress.h" @@ -12,20 +13,36 @@ namespace jingle_glue { FakeNetworkManager::FakeNetworkManager(const net::IPAddressNumber& address) - : address_(address) { + : started_(false), + ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { + net::IPEndPoint endpoint(address, 0); + talk_base::SocketAddress socket_address; + CHECK(IPEndPointToSocketAddress(endpoint, &socket_address)); + network_.reset(new talk_base::Network("fake", "Fake Network", + socket_address.ip(), 0)); } FakeNetworkManager::~FakeNetworkManager() { } -bool FakeNetworkManager::EnumNetworks( - bool include_ignored, std::vector<talk_base::Network*>* networks) { - net::IPEndPoint endpoint(address_, 0); - talk_base::SocketAddress address; - CHECK(IPEndPointToSocketAddress(endpoint, &address)); - networks->push_back(new talk_base::Network( - "fake", "Fake Network", address.ip(), 0)); - return true; +void FakeNetworkManager::StartUpdating() { + started_ = true; + MessageLoop::current()->PostTask( + FROM_HERE,task_factory_.NewRunnableMethod( + &FakeNetworkManager::SendNetworksChangedSignal)); +} + +void FakeNetworkManager::StopUpdating() { + started_ = false; +} + +void FakeNetworkManager::GetNetworks(NetworkList* networks) const { + networks->clear(); + networks->push_back(network_.get()); +} + +void FakeNetworkManager::SendNetworksChangedSignal() { + SignalNetworksChanged(); } } // namespace jingle_glue diff --git a/jingle/glue/fake_network_manager.h b/jingle/glue/fake_network_manager.h index f099c3c..ad39e6b 100644 --- a/jingle/glue/fake_network_manager.h +++ b/jingle/glue/fake_network_manager.h @@ -8,6 +8,8 @@ #include <vector> #include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "base/task.h" #include "net/base/net_util.h" #include "third_party/libjingle/source/talk/base/network.h" @@ -20,13 +22,18 @@ class FakeNetworkManager : public talk_base::NetworkManager { FakeNetworkManager(const net::IPAddressNumber& address); virtual ~FakeNetworkManager(); + // talk_base::NetworkManager interface. + virtual void StartUpdating() OVERRIDE; + virtual void StopUpdating() OVERRIDE; + virtual void GetNetworks(NetworkList* networks) const OVERRIDE; + protected: - // Override from talk_base::NetworkManager. - virtual bool EnumNetworks( - bool include_ignored, - std::vector<talk_base::Network*>* networks) OVERRIDE; + void SendNetworksChangedSignal(); + + bool started_; + scoped_ptr<talk_base::Network> network_; - net::IPAddressNumber address_; + ScopedRunnableMethodFactory<FakeNetworkManager> task_factory_; }; } // namespace jingle_glue |