| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 5 #ifndef CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| 6 #define CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 6 #define CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
| 15 #include "chromeos/dbus/services/cros_dbus_service.h" | 15 #include "chromeos/dbus/services/cros_dbus_service.h" |
| 16 #include "dbus/exported_object.h" | 16 #include "dbus/exported_object.h" |
| 17 #include "net/base/completion_callback.h" |
| 18 |
| 19 class GURL; |
| 17 | 20 |
| 18 namespace base { | 21 namespace base { |
| 19 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
| 20 } | 23 } |
| 21 | 24 |
| 22 namespace dbus { | 25 namespace dbus { |
| 23 class MethodCall; | 26 class MethodCall; |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace net { | 29 namespace net { |
| 30 class ProxyInfo; |
| 31 class ProxyService; |
| 27 class URLRequestContextGetter; | 32 class URLRequestContextGetter; |
| 28 } | 33 } |
| 29 | 34 |
| 30 namespace chromeos { | 35 namespace chromeos { |
| 31 | 36 |
| 32 class ProxyResolverDelegate; | 37 class ProxyResolverDelegate; |
| 33 class ProxyResolverInterface; | 38 class ProxyResolverInterface; |
| 34 | 39 |
| 35 // This class provides proxy resolution service for CrosDBusService. | 40 // This class provides proxy resolution service for CrosDBusService. |
| 36 // It processes proxy resolution requests for ChromeOS clients. | 41 // It processes proxy resolution requests for ChromeOS clients. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 }; | 132 }; |
| 128 | 133 |
| 129 // The delegate which provides necessary objects to the proxy resolver. | 134 // The delegate which provides necessary objects to the proxy resolver. |
| 130 class CHROMEOS_EXPORT ProxyResolverDelegate { | 135 class CHROMEOS_EXPORT ProxyResolverDelegate { |
| 131 public: | 136 public: |
| 132 virtual ~ProxyResolverDelegate() {} | 137 virtual ~ProxyResolverDelegate() {} |
| 133 | 138 |
| 134 // Returns the request context used to perform proxy resolution. | 139 // Returns the request context used to perform proxy resolution. |
| 135 // Always called on UI thread. | 140 // Always called on UI thread. |
| 136 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; | 141 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; |
| 142 |
| 143 // Thin wrapper around net::ProxyService::ResolveProxy() to make testing |
| 144 // easier. |
| 145 virtual int ResolveProxy(net::ProxyService* proxy_service, |
| 146 const GURL& url, |
| 147 net::ProxyInfo* results, |
| 148 const net::CompletionCallback& callback) = 0; |
| 137 }; | 149 }; |
| 138 | 150 |
| 139 // The interface is defined so we can mock out the proxy resolver | 151 // The interface is defined so we can mock out the proxy resolver |
| 140 // implementation. | 152 // implementation. |
| 141 class CHROMEOS_EXPORT ProxyResolverInterface { | 153 class CHROMEOS_EXPORT ProxyResolverInterface { |
| 142 public: | 154 public: |
| 143 // Resolves the proxy for the given URL. Returns the result as a | 155 // Resolves the proxy for the given URL. Returns the result as a |
| 144 // signal sent to |signal_interface| and | 156 // signal sent to |signal_interface| and |
| 145 // |signal_name|. |exported_object| will be used to send the | 157 // |signal_name|. |exported_object| will be used to send the |
| 146 // signal. The signal contains the three string members: | 158 // signal. The signal contains the three string members: |
| 147 // | 159 // |
| 148 // - source url: the requested source URL. | 160 // - source url: the requested source URL. |
| 149 // - proxy info: proxy info for the source URL in PAC format. | 161 // - proxy info: proxy info for the source URL in PAC format. |
| 150 // - error message: empty if the proxy resolution was successful. | 162 // - error message: empty if the proxy resolution was successful. |
| 151 virtual void ResolveProxy( | 163 virtual void ResolveProxy( |
| 152 const std::string& source_url, | 164 const std::string& source_url, |
| 153 const std::string& signal_interface, | 165 const std::string& signal_interface, |
| 154 const std::string& signal_name, | 166 const std::string& signal_name, |
| 155 scoped_refptr<dbus::ExportedObject> exported_object) = 0; | 167 scoped_refptr<dbus::ExportedObject> exported_object) = 0; |
| 156 | 168 |
| 157 virtual ~ProxyResolverInterface(); | 169 virtual ~ProxyResolverInterface(); |
| 158 }; | 170 }; |
| 159 | 171 |
| 160 } // namespace chromeos | 172 } // namespace chromeos |
| 161 | 173 |
| 162 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 174 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| OLD | NEW |