Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: webrtc/base/fakenetwork.h

Issue 1361773005: Reland of TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/session/media/channelmanager_unittest.cc ('k') | webrtc/p2p/base/dtlstransport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/fakenetwork.h
diff --git a/webrtc/base/fakenetwork.h b/webrtc/base/fakenetwork.h
index 4b6bb68a96d9450bc82330534ae05cea0861d081..065d08d4c19c8f32f380a7ce8304fa6f599cff59 100644
--- a/webrtc/base/fakenetwork.h
+++ b/webrtc/base/fakenetwork.h
@@ -29,12 +29,7 @@
class FakeNetworkManager : public NetworkManagerBase,
public MessageHandler {
public:
- FakeNetworkManager()
- : thread_(Thread::Current()),
- next_index_(0),
- started_(false),
- sent_first_update_(false) {
- }
+ FakeNetworkManager() : thread_(Thread::Current()) {}
typedef std::vector<SocketAddress> IfaceList;
@@ -58,20 +53,18 @@
}
virtual void StartUpdating() {
- if (started_) {
- if (sent_first_update_)
+ ++start_count_;
+ if (start_count_ == 1) {
+ sent_first_update_ = false;
+ thread_->Post(this);
+ } else {
+ if (sent_first_update_) {
SignalNetworksChanged();
- return;
+ }
}
-
- started_ = true;
- sent_first_update_ = false;
- thread_->Post(this);
}
- virtual void StopUpdating() {
- started_ = false;
- }
+ virtual void StopUpdating() { --start_count_; }
// MessageHandler interface.
virtual void OnMessage(Message* msg) {
@@ -82,7 +75,7 @@
private:
void DoUpdateNetworks() {
- if (!started_)
+ if (start_count_ == 0)
return;
std::vector<Network*> networks;
for (IfaceList::iterator it = ifaces_.begin();
@@ -111,9 +104,9 @@
Thread* thread_;
IfaceList ifaces_;
- int next_index_;
- bool started_;
- bool sent_first_update_;
+ int next_index_ = 0;
+ int start_count_ = 0;
+ bool sent_first_update_ = false;
};
} // namespace rtc
« no previous file with comments | « talk/session/media/channelmanager_unittest.cc ('k') | webrtc/p2p/base/dtlstransport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698