| Index: chromeos/network/connection_change_notifier.h
|
| diff --git a/chromeos/network/connection_change_notifier.h b/chromeos/network/connection_change_notifier.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..05081953eeda5e8564a799ae2c983dd518c06b97
|
| --- /dev/null
|
| +++ b/chromeos/network/connection_change_notifier.h
|
| @@ -0,0 +1,96 @@
|
| +// 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/chromeos_export.h"
|
| +#include "chromeos/network/network_state_handler_observer.h"
|
| +#include "net/base/network_change_notifier.h"
|
| +#include "net/dns/dns_config_service_posix.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +class CHROMEOS_EXPORT ConnectionChangeNotifier
|
| + : public net::NetworkChangeNotifier,
|
| + public chromeos::NetworkStateHandlerObserver {
|
| + public:
|
| + ConnectionChangeNotifier();
|
| + virtual ~ConnectionChangeNotifier();
|
| +
|
| + // Initialize the connection change notifier. Start observing
|
| + // changes from the network state handler.
|
| + void Initialize();
|
| +
|
| + // Shutdown the connection change notifier. Stop observing
|
| + // changes from the network state handler.
|
| + void Shutdown();
|
| +
|
| + // NetworkChangeNotifier overrides.
|
| + net::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 ConnectionChangeNotifierUpdateTest;
|
| +
|
| + class DnsConfigServiceChromeos : public net::internal::DnsConfigServicePosix {
|
| + public:
|
| + DnsConfigServiceChromeos();
|
| + virtual ~DnsConfigServiceChromeos();
|
| +
|
| + // net::Internal::DnsConfigService() overrides.
|
| + virtual bool StartWatching() OVERRIDE;
|
| +
|
| + virtual void OnNetworkChange();
|
| + };
|
| +
|
| + // Maps the shill network type and technology to its NetworkChangeNotifier
|
| + // equivalent.
|
| + static net::NetworkChangeNotifier::ConnectionType
|
| + ConnectionTypeFromShill(const std::string& type,
|
| + const std::string& technology);
|
| +
|
| + // 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,
|
| + bool* connection_type_changed,
|
| + bool* ip_address_changed,
|
| + bool* dns_changed);
|
| +
|
| + // Notify observers of NetworkChangeNotifier that the type of connection
|
| + // changed.
|
| + void ReportConnectionTypeChanged();
|
| + // Notify observers of NetworkChangeNotifier that the IP address changed.
|
| + void ReportIPAddressChanged();
|
| +
|
| + net::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<DnsConfigServiceChromeos> dns_config_service_;
|
| +
|
| + FRIEND_TEST_ALL_PREFIXES(ConnectionChangeNotifierTest,
|
| + ConnectionTypeFromShill);
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ConnectionChangeNotifier);
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROMEOS_CONNECTION_CHANGE_NOTIFIER_H_
|
|
|