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

Side by Side Diff: net/base/network_change_notifier_mac.h

Issue 10377092: [net/dns] Isolate DnsConfigWatcher from DnsConfigService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Braces. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
7 #pragma once 7 #pragma once
8 8
9 #include <SystemConfiguration/SystemConfiguration.h> 9 #include <SystemConfiguration/SystemConfiguration.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/condition_variable.h" 15 #include "base/synchronization/condition_variable.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "net/base/network_change_notifier.h" 17 #include "net/base/network_change_notifier.h"
18 #include "net/base/network_config_watcher_mac.h" 18 #include "net/base/network_config_watcher_mac.h"
19 19
20 namespace net { 20 namespace net {
21 21
22 class NetworkChangeNotifierMac: public NetworkChangeNotifier { 22 class NetworkChangeNotifierMac: public NetworkChangeNotifier {
23 public: 23 public:
24 NetworkChangeNotifierMac(); 24 NetworkChangeNotifierMac();
25 virtual ~NetworkChangeNotifierMac(); 25 virtual ~NetworkChangeNotifierMac();
26 26
27 // NetworkChangeNotifier implementation: 27 // NetworkChangeNotifier:
28 virtual bool IsCurrentlyOffline() const OVERRIDE; 28 virtual bool IsCurrentlyOffline() const OVERRIDE;
29 29
30 private: 30 private:
31 enum OnlineState { 31 enum OnlineState {
32 UNINITIALIZED = -1, 32 UNINITIALIZED = -1,
33 OFFLINE = 0, 33 OFFLINE = 0,
34 ONLINE = 1 34 ONLINE = 1
35 }; 35 };
36 36
37 class DnsWatcherThread;
38
37 // Forwarder just exists to keep the NetworkConfigWatcherMac API out of 39 // Forwarder just exists to keep the NetworkConfigWatcherMac API out of
38 // NetworkChangeNotifierMac's public API. 40 // NetworkChangeNotifierMac's public API.
39 class Forwarder : public NetworkConfigWatcherMac::Delegate { 41 class Forwarder : public NetworkConfigWatcherMac::Delegate {
40 public: 42 public:
41 explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher) 43 explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher)
42 : net_config_watcher_(net_config_watcher) {} 44 : net_config_watcher_(net_config_watcher) {}
43 45
44 // NetworkConfigWatcherMac::Delegate implementation: 46 // NetworkConfigWatcherMac::Delegate implementation:
45 virtual void Init() OVERRIDE { 47 virtual void Init() OVERRIDE {
46 net_config_watcher_->SetInitialState(); 48 net_config_watcher_->SetInitialState();
(...skipping 29 matching lines...) Expand all
76 // the lock is in a valid state when Forwarder::Init is called. 78 // the lock is in a valid state when Forwarder::Init is called.
77 OnlineState online_state_; 79 OnlineState online_state_;
78 mutable base::Lock online_state_lock_; 80 mutable base::Lock online_state_lock_;
79 mutable base::ConditionVariable initial_state_cv_; 81 mutable base::ConditionVariable initial_state_cv_;
80 base::mac::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_; 82 base::mac::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_;
81 base::mac::ScopedCFTypeRef<CFRunLoopRef> run_loop_; 83 base::mac::ScopedCFTypeRef<CFRunLoopRef> run_loop_;
82 84
83 Forwarder forwarder_; 85 Forwarder forwarder_;
84 scoped_ptr<const NetworkConfigWatcherMac> config_watcher_; 86 scoped_ptr<const NetworkConfigWatcherMac> config_watcher_;
85 87
88 // Thread on which we can run DnsConfigWatcher, which requires TYPE_IO.
89 scoped_ptr<DnsWatcherThread> dns_watcher_thread_;
90
86 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); 91 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac);
87 }; 92 };
88 93
89 } // namespace net 94 } // namespace net
90 95
91 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ 96 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698