Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_NETWORK_HOST_RESOLVER_IMPL_CHROMEOS_H_ | |
| 6 #define CHROMEOS_NETWORK_HOST_RESOLVER_IMPL_CHROMEOS_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/threading/thread_checker.h" | |
| 10 #include "chromeos/chromeos_export.h" | |
| 11 #include "net/dns/host_resolver_impl.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class MessageLoopProxy; | |
| 15 } | |
| 16 | |
| 17 namespace chromeos { | |
| 18 class NetworkStateHandler; | |
| 19 } | |
| 20 | |
| 21 namespace net { | |
|
eroman
2014/06/05 22:58:24
Is this a typical namespace for chromeos/network c
stevenjb
2014/06/06 16:06:03
Yes, it should be in chromeos::. I did this initia
| |
| 22 | |
| 23 // HostResolverImplChromeOS overrides HostResolverImpl::Resolve in order to | |
| 24 // provide the correct IP addresses for localhost using the chromeos | |
| 25 // NetworkHandler interface. ('hostname' only returns 'localhost' on cros). | |
| 26 | |
| 27 class CHROMEOS_EXPORT HostResolverImplChromeOS : public HostResolverImpl { | |
| 28 public: | |
| 29 // ChromeOS specific implementation of HostResolver::CreateSystemResolver. | |
| 30 // Assumes NetworkHandler has been initialized. | |
| 31 // This is expected to be constructed on the same thread that Resolve() is | |
| 32 // called from, i.e. the IO thread, which is presumed to differ from the | |
| 33 // thread that NetworkStateHandler is called on, i.e. the UI thread. | |
| 34 static scoped_ptr<HostResolver> CreateSystemResolver( | |
| 35 const Options& options, | |
| 36 NetLog* net_log); | |
| 37 | |
| 38 // Creates a host resolver instance for testing. | |
| 39 static scoped_ptr<HostResolver> CreateHostResolverForTest( | |
| 40 scoped_refptr<base::MessageLoopProxy> ui_message_loop, | |
| 41 chromeos::NetworkStateHandler* network_state_handler); | |
| 42 | |
| 43 virtual ~HostResolverImplChromeOS(); | |
| 44 | |
| 45 // HostResolverImpl | |
| 46 virtual int Resolve(const RequestInfo& info, | |
| 47 RequestPriority priority, | |
| 48 AddressList* addresses, | |
| 49 const CompletionCallback& callback, | |
| 50 RequestHandle* out_req, | |
| 51 const BoundNetLog& source_net_log) OVERRIDE; | |
| 52 | |
| 53 private: | |
| 54 class NetworkObserver; | |
| 55 | |
| 56 HostResolverImplChromeOS( | |
| 57 scoped_refptr<base::MessageLoopProxy> ui_message_loop, | |
| 58 chromeos::NetworkStateHandler* network_state_handler, | |
| 59 scoped_ptr<HostCache> cache, | |
| 60 const PrioritizedDispatcher::Limits& job_limits, | |
| 61 const ProcTaskParams& proc_params, | |
| 62 NetLog* net_log); | |
| 63 void CreateNetworkObserver( | |
| 64 scoped_refptr<base::MessageLoopProxy> io_message_loop, | |
| 65 chromeos::NetworkStateHandler* network_state_handler); | |
| 66 bool ResolveLocalIPAddress(const RequestInfo& info, | |
| 67 AddressList* addresses); | |
| 68 | |
| 69 base::ThreadChecker thread_checker_; | |
| 70 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; | |
| 71 scoped_ptr<NetworkObserver> network_observer_; | |
| 72 base::WeakPtrFactory<HostResolverImplChromeOS> weak_ptr_factory_ui_thread_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(HostResolverImplChromeOS); | |
| 75 }; | |
| 76 | |
| 77 } // namespace net | |
| 78 | |
| 79 #endif // CHROMEOS_NETWORK_HOST_RESOLVER_IMPL_CHROMEOS_H_ | |
| OLD | NEW |