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

Unified Diff: net/base/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: Move to net/base 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
Index: net/base/network_change_notifier_chromeos.h
diff --git a/net/base/network_change_notifier_chromeos.h b/net/base/network_change_notifier_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..bcb2e2ce2e5428581934d391b715e98657f50540
--- /dev/null
+++ b/net/base/network_change_notifier_chromeos.h
@@ -0,0 +1,94 @@
+// 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_CONNECTION_CHANGE_NOTIFIER_H_
+#define CHROMEOS_NETWORK_CONNECTION_CHANGE_NOTIFIER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "chromeos/network/network_state_handler_observer.h"
+#include "net/base/net_export.h"
+#include "net/base/network_change_notifier.h"
+#include "net/dns/dns_config_service_posix.h"
+
+namespace net {
+
+class NET_EXPORT_PRIVATE NetworkChangeNotifierChromeos
+ : public NetworkChangeNotifier,
+ public chromeos::NetworkStateHandlerObserver {
+ public:
+ NetworkChangeNotifierChromeos();
+ virtual ~NetworkChangeNotifierChromeos();
+
+ // Initialize the connection change notifier. Start observing
+ // changes from the network state handler.
stevenjb 2012/12/13 19:28:22 Simplify to: Starts observing changes from the net
gauravsh 2012/12/15 00:42:45 Done.
+ void Initialize();
+
+ // Shutdown the connection change notifier. Stop observing
+ // changes from the network state handler.
stevenjb 2012/12/13 19:28:22 dito. s/Stop/Stops
gauravsh 2012/12/15 00:42:45 Done.
+ void Shutdown();
+
+ // NetworkChangeNotifier overrides.
+ NetworkChangeNotifier::ConnectionType
+ GetCurrentConnectionType() const OVERRIDE;
+
+ // NetworkStateHandlerObserver overrides.
+ void ActiveNetworkChanged(
+ const chromeos::NetworkState* active_network) OVERRIDE;
+ void ActiveNetworkStateChanged(
+ const chromeos::NetworkState* active_network) OVERRIDE;
+
+ private:
+ friend class NetworkChangeNotifierChromeosUpdateTest;
+
+ class DnsConfigService : public net::internal::DnsConfigServicePosix {
stevenjb 2012/12/13 19:28:22 We can define this only in the .cc file and forwar
gauravsh 2012/12/15 00:42:45 Done.
+ public:
+ DnsConfigService();
+ virtual ~DnsConfigService();
+
+ // net::internal::DnsConfigService() overrides.
+ virtual bool StartWatching() OVERRIDE;
+
+ virtual void OnNetworkChange();
+ };
+
+ // Updates the 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 UpdateActiveNetwork(const chromeos::NetworkState* active_network,
stevenjb 2012/12/13 19:28:22 It looks like this doesn't actually do any updatin
gauravsh 2012/12/15 00:42:45 Changed this to UpdateState(), since it's changing
+ bool* connection_type_changed,
+ bool* ip_address_changed,
+ bool* dns_changed);
+
+ // Maps the shill network type and technology to its NetworkChangeNotifier
+ // equivalent.
+ static NetworkChangeNotifier::ConnectionType
+ ConnectionTypeFromShill(const std::string& type,
+ const std::string& technology);
+
+ // Calculates parameters used for network change notifier online/offline
+ // signals.
+ static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsChromeos();
+
+ NetworkChangeNotifier::ConnectionType connection_type_;
stevenjb 2012/12/13 19:28:22 We should be consistent with whether or not we use
gauravsh 2012/12/15 00:42:45 Made it consistent. I prefer the qualifier because
+ // 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_;
+
+ FRIEND_TEST_ALL_PREFIXES(NetworkChangeNotifierChromeosTest,
+ ConnectionTypeFromShill);
stevenjb 2012/12/13 19:28:22 FRIEND* should be just below private
gauravsh 2012/12/15 00:42:45 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_CONNECTION_CHANGE_NOTIFIER_H_

Powered by Google App Engine
This is Rietveld 408576698