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

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

Issue 394103004: Move DnsApiTest.DnsResolveIPLiteral and DnsApiTest.DnsResolveHostname to app_shell_browsertests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: correcter gyp Created 6 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_ 5 #ifndef EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_
6 #define EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_ 6 #define EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_
7 7
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "net/dns/host_resolver.h" 9
10 namespace content {
11 class ResourceContext;
12 }
13
14 namespace net {
15 class HostResolver;
16 }
10 17
11 namespace extensions { 18 namespace extensions {
12 19
13 // Used for testing. In production code, this class does nothing interesting. 20 // Used for testing. In production code, this class does nothing interesting.
14 // This class is a singleton that holds a pointer to a mock HostResolver, or 21 // This class is a singleton that holds a pointer to a mock HostResolver, or
15 // else to NULL. API classes that need to resolve hostnames ask this class for 22 // else to NULL. API classes that need to resolve hostnames ask this class for
16 // the correct HostResolver to use, passing in the one that they want to use, 23 // the correct HostResolver to use, passing in the one that they want to use,
17 // thereby avoiding most lifetime issues, and it will reply with either that 24 // thereby avoiding most lifetime issues, and it will reply with either that
18 // same one, or else the test version to use instead. 25 // same one, or else the test version to use instead.
19 // 26 //
20 // This is a pretty complicated way to replace a single pointer with another. 27 // This is a pretty complicated way to replace a single pointer with another.
21 // TODO(miket): make the previous statement obsolete. 28 // TODO(miket): make the previous statement obsolete.
22 class HostResolverWrapper { 29 class HostResolverWrapper {
23 public: 30 public:
24 static HostResolverWrapper* GetInstance(); 31 static HostResolverWrapper* GetInstance();
25 32
26 // Given a pointer to a real host resolver, returns the same pointer or else 33 // Given a pointer to a ResourceContext, returns its HostResolver if
27 // a substitute MockHostResolver to use instead. If 34 // SetHostResolverForTesting() hasn't been called, or else a
28 // SetHostResolverForTesting() hasn't been called, then this method returns 35 // a substitute MockHostResolver to use instead.
29 // the supplied argument as its result. 36 net::HostResolver* GetHostResolver(content::ResourceContext* context);
30 net::HostResolver* GetHostResolver(net::HostResolver* real_resolver);
31 37
32 // Sets the MockHostResolver to return in GetHostResolver(). 38 // Sets the MockHostResolver to return in GetHostResolver().
33 void SetHostResolverForTesting(net::HostResolver* mock_resolver); 39 void SetHostResolverForTesting(net::HostResolver* mock_resolver);
34 40
35 private: 41 private:
36 HostResolverWrapper(); 42 HostResolverWrapper();
37 friend struct DefaultSingletonTraits<HostResolverWrapper>; 43 friend struct DefaultSingletonTraits<HostResolverWrapper>;
38 44
39 net::HostResolver* resolver_; 45 net::HostResolver* resolver_;
40 46
41 DISALLOW_COPY_AND_ASSIGN(HostResolverWrapper); 47 DISALLOW_COPY_AND_ASSIGN(HostResolverWrapper);
42 }; 48 };
43 49
44 } // namespace extensions 50 } // namespace extensions
45 51
46 #endif // EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_ 52 #endif // EXTENSIONS_BROWSER_API_DNS_HOST_RESOLVER_WRAPPER_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/dns/dns_api.cc ('k') | extensions/browser/api/dns/host_resolver_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698