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

Unified Diff: chromeos/network/network_change_notifier_chromeos.h

Issue 11469044: Implement new network change notifier that uses NetworkStateHandler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix clang warning (missing virtual on OVERRIDE) Created 8 years 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 | « chromeos/network/managed_state.h ('k') | chromeos/network/network_change_notifier_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_change_notifier_chromeos.h
diff --git a/chromeos/network/network_change_notifier_chromeos.h b/chromeos/network/network_change_notifier_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..ca22588992b49f8dc41d1cefff76da6ae0fcf0e2
--- /dev/null
+++ b/chromeos/network/network_change_notifier_chromeos.h
@@ -0,0 +1,83 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
+#define CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/network/network_state_handler_observer.h"
+#include "net/base/network_change_notifier.h"
+
+namespace chromeos {
+
+class CHROMEOS_EXPORT NetworkChangeNotifierChromeos
+ : public net::NetworkChangeNotifier,
+ public chromeos::NetworkStateHandlerObserver {
+ public:
+ NetworkChangeNotifierChromeos();
+ virtual ~NetworkChangeNotifierChromeos();
+
+ // Starts observing changes from the network state handler.
+ void Initialize();
+
+ // Stops observing changes from the network state handler.
+ void Shutdown();
+
+ // NetworkChangeNotifier overrides.
+ virtual net::NetworkChangeNotifier::ConnectionType
+ GetCurrentConnectionType() const OVERRIDE;
+
+ // NetworkStateHandlerObserver overrides.
+ virtual void ActiveNetworkChanged(
+ const chromeos::NetworkState* active_network) OVERRIDE;
+ virtual void ActiveNetworkStateChanged(
+ const chromeos::NetworkState* active_network) OVERRIDE;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest,
+ ConnectionTypeFromShill);
+ friend class NetworkChangeNotifierChromeosUpdateTest;
+
+ class DnsConfigService;
+
+ // Updates the notifier state based on an active network update.
+ // |connection_type_changed| is set to true if we must report a connection
+ // type change.
+ // |ip_address_changed| is set to true if we must report an IP address change.
+ // |dns_changed| is set to true if we must report a DNS config change.
+ void UpdateState(const chromeos::NetworkState* active_network,
+ bool* connection_type_changed,
+ bool* ip_address_changed,
+ bool* dns_changed);
+
+ // Maps the shill network type and technology to its NetworkChangeNotifier
+ // equivalent.
+ static net::NetworkChangeNotifier::ConnectionType
+ ConnectionTypeFromShill(const std::string& type,
+ const std::string& technology);
+
+ // Calculates parameters used for network change notifier online/offline
+ // signals.
+ static net::NetworkChangeNotifier::NetworkChangeCalculatorParams
+ NetworkChangeCalculatorParamsChromeos();
+
+ NetworkChangeNotifier::ConnectionType connection_type_;
+ // IP address for the current active network.
+ std::string ip_address_;
+ // Service path for the current active network.
+ std::string service_path_;
+
+ scoped_ptr<DnsConfigService> dns_config_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_NETWORK_NETWORK_CHANGE_NOTIFIER_CHROMEOS_H_
« no previous file with comments | « chromeos/network/managed_state.h ('k') | chromeos/network/network_change_notifier_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698