OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 NET_PROXY_TEST_MOJO_PROXY_RESOLVER_FACTORY_H_ |
| 6 #define NET_PROXY_TEST_MOJO_PROXY_RESOLVER_FACTORY_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/singleton.h" |
| 13 #include "net/proxy/mojo_proxy_resolver_factory.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 // MojoProxyResolverFactory that runs PAC scripts in-process, for tests. |
| 18 class TestMojoProxyResolverFactory : public MojoProxyResolverFactory { |
| 19 public: |
| 20 static TestMojoProxyResolverFactory* GetInstance(); |
| 21 |
| 22 // Returns true if CreateResolver was called. |
| 23 bool resolver_created() { return resolver_created_; } |
| 24 |
| 25 // Sets the value returned by resolver_created. Since this is a singleton, |
| 26 // Serves to avoid with test fixture reuse. |
| 27 void set_resolver_created(bool resolver_created) { |
| 28 resolver_created_ = resolver_created; |
| 29 } |
| 30 |
| 31 // Overridden from MojoProxyResolverFactory: |
| 32 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( |
| 33 const std::string& pac_script, |
| 34 mojo::InterfaceRequest<interfaces::ProxyResolver> req, |
| 35 interfaces::ProxyResolverFactoryRequestClientPtr client) override; |
| 36 |
| 37 private: |
| 38 TestMojoProxyResolverFactory(); |
| 39 ~TestMojoProxyResolverFactory() override; |
| 40 |
| 41 friend struct base::DefaultSingletonTraits<TestMojoProxyResolverFactory>; |
| 42 |
| 43 interfaces::ProxyResolverFactoryPtr factory_; |
| 44 |
| 45 bool resolver_created_ = false; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(TestMojoProxyResolverFactory); |
| 48 }; |
| 49 |
| 50 } // namespace net |
| 51 |
| 52 #endif // NET_PROXY_TEST_MOJO_PROXY_RESOLVER_FACTORY_H_ |
OLD | NEW |