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

Unified Diff: webrtc/base/fakenetwork.h

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 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
Index: webrtc/base/fakenetwork.h
diff --git a/webrtc/base/fakenetwork.h b/webrtc/base/fakenetwork.h
index 4b6bb68a96d9450bc82330534ae05cea0861d081..896be99b1de3a2598889328424e3ac88c53f955b 100644
--- a/webrtc/base/fakenetwork.h
+++ b/webrtc/base/fakenetwork.h
@@ -29,12 +29,7 @@ const int kFakeIPv6NetworkPrefixLength = 64;
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,16 @@ class FakeNetworkManager : public NetworkManagerBase,
}
virtual void StartUpdating() {
- if (started_) {
+ if (start_count_++ == 0) {
pthatcher1 2015/08/31 22:01:35 That's a bit too subtle for me. How about this?
Taylor Brandstetter 2015/09/01 23:53:30 Done.
+ 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 +73,7 @@ class FakeNetworkManager : public NetworkManagerBase,
private:
void DoUpdateNetworks() {
- if (!started_)
+ if (start_count_ == 0)
return;
std::vector<Network*> networks;
for (IfaceList::iterator it = ifaces_.begin();
@@ -111,9 +102,9 @@ class FakeNetworkManager : public NetworkManagerBase,
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

Powered by Google App Engine
This is Rietveld 408576698