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

Side by Side Diff: chrome/browser/extensions/api/dns/host_resolver_wrapper.h

Issue 10537017: Allow hostnames in socket.connect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Set 1 Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DNS_HOST_RESOLVER_WRAPPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DNS_HOST_RESOLVER_WRAPPER_H_
7 #pragma once
8
9 #include "base/memory/singleton.h"
10 #include "net/base/host_resolver.h"
11
12 namespace extensions {
13
14 // Used for testing. In production code, this class does nothing interesting.
15 // This class is a singleton that holds a pointer to a mock HostResolver, or
16 // else to NULL. API classes that need to resolve hostnames ask this class for
17 // the correct HostResolver to use, passing in the one that they want to use,
18 // thereby avoiding most lifetime issues, and it will reply with either that
19 // same one, or else the test version to use instead.
20 //
21 // This is a pretty complicated way to replace a single pointer with another.
22 // TODO(miket): make the previous statement obsolete.
23 class HostResolverWrapper {
24 public:
25 static HostResolverWrapper* GetInstance();
26
27 // Given a pointer to a real host resolver, returns the same pointer or else
28 // a substitute MockHostResolver to use instead. If
29 // SetHostResolverForTesting() hasn't been called, then this method returns
30 // the supplied argument as its result.
31 net::HostResolver* GetHostResolver(net::HostResolver* real_resolver);
32
33 // Sets the MockHostResolver to return in GetHostResolver().
34 void SetHostResolverForTesting(net::HostResolver* mock_resolver);
35
36 private:
37 HostResolverWrapper();
38 friend struct DefaultSingletonTraits<HostResolverWrapper>;
39
40 net::HostResolver* resolver_;
41
42 DISALLOW_COPY_AND_ASSIGN(HostResolverWrapper);
43 };
44
45 } // namespace extensions
46
47 #endif // CHROME_BROWSER_EXTENSIONS_API_DNS_HOST_RESOLVER_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698