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

Unified Diff: chromeos/network/host_resolver_impl_chromeos.h

Issue 238433003: Provide Shill IP Address to myIpAddress() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/network/host_resolver_impl_chromeos.h
diff --git a/chromeos/network/host_resolver_impl_chromeos.h b/chromeos/network/host_resolver_impl_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..57b18f6af1cc001f0dfc3bef9455d905dd082df9
--- /dev/null
+++ b/chromeos/network/host_resolver_impl_chromeos.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2014 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_HOST_RESOLVER_IMPL_CHROMEOS_H_
+#define CHROMEOS_NETWORK_HOST_RESOLVER_IMPL_CHROMEOS_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/threading/thread_checker.h"
+#include "chromeos/chromeos_export.h"
+#include "net/dns/host_resolver_impl.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace chromeos {
+class NetworkStateHandler;
+}
+
+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
+
+// HostResolverImplChromeOS overrides HostResolverImpl::Resolve in order to
+// provide the correct IP addresses for localhost using the chromeos
+// NetworkHandler interface. ('hostname' only returns 'localhost' on cros).
+
+class CHROMEOS_EXPORT HostResolverImplChromeOS : public HostResolverImpl {
+ public:
+ // ChromeOS specific implementation of HostResolver::CreateSystemResolver.
+ // Assumes NetworkHandler has been initialized.
+ // This is expected to be constructed on the same thread that Resolve() is
+ // called from, i.e. the IO thread, which is presumed to differ from the
+ // thread that NetworkStateHandler is called on, i.e. the UI thread.
+ static scoped_ptr<HostResolver> CreateSystemResolver(
+ const Options& options,
+ NetLog* net_log);
+
+ // Creates a host resolver instance for testing.
+ static scoped_ptr<HostResolver> CreateHostResolverForTest(
+ scoped_refptr<base::MessageLoopProxy> ui_message_loop,
+ chromeos::NetworkStateHandler* network_state_handler);
+
+ virtual ~HostResolverImplChromeOS();
+
+ // HostResolverImpl
+ virtual int Resolve(const RequestInfo& info,
+ RequestPriority priority,
+ AddressList* addresses,
+ const CompletionCallback& callback,
+ RequestHandle* out_req,
+ const BoundNetLog& source_net_log) OVERRIDE;
+
+ private:
+ class NetworkObserver;
+
+ HostResolverImplChromeOS(
+ scoped_refptr<base::MessageLoopProxy> ui_message_loop,
+ chromeos::NetworkStateHandler* network_state_handler,
+ scoped_ptr<HostCache> cache,
+ const PrioritizedDispatcher::Limits& job_limits,
+ const ProcTaskParams& proc_params,
+ NetLog* net_log);
+ void CreateNetworkObserver(
+ scoped_refptr<base::MessageLoopProxy> io_message_loop,
+ chromeos::NetworkStateHandler* network_state_handler);
+ bool ResolveLocalIPAddress(const RequestInfo& info,
+ AddressList* addresses);
+
+ base::ThreadChecker thread_checker_;
+ scoped_refptr<base::MessageLoopProxy> ui_message_loop_;
+ scoped_ptr<NetworkObserver> network_observer_;
+ base::WeakPtrFactory<HostResolverImplChromeOS> weak_ptr_factory_ui_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostResolverImplChromeOS);
+};
+
+} // namespace net
+
+#endif // CHROMEOS_NETWORK_HOST_RESOLVER_IMPL_CHROMEOS_H_

Powered by Google App Engine
This is Rietveld 408576698