Guard network notification callback by check if state was changed

Existed solution was to noisy and triggered a lot of XMPP pings.

Change-Id: I6d95d5f7323e9a15fcc088b766ba903d83bccbb1
Reviewed-on: https://weave-review.googlesource.com/1381
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/examples/provider/event_network.cc b/libweave/examples/provider/event_network.cc
index d3a3391..ed308f0 100644
--- a/libweave/examples/provider/event_network.cc
+++ b/libweave/examples/provider/event_network.cc
@@ -83,9 +83,14 @@
   if (state != network_state_) {
     LOG(INFO) << "network state updated: " << weave::EnumToString(state);
     network_state_ = state;
+
+    // In general it's better to send false notification than miss one.
+    // However current implementation can only send them very often on every
+    // UpdateNetworkStateCallback or just here, guarder with this if condition.
+    for (const auto& cb : callbacks_)
+      cb.Run();
   }
-  for (const auto& cb : callbacks_)
-    cb.Run();
+
   // TODO(proppy): use netlink interface event instead of polling
   task_runner_->PostDelayedTask(
       FROM_HERE, base::Bind(&EventNetworkImpl::UpdateNetworkState,