| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace dbus { | 23 namespace dbus { |
| 24 class MethodCall; | 24 class MethodCall; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace chromeos { | 31 namespace chromeos { |
| 32 | 32 |
| 33 // This class provides proxy resolution service for CrosDBusService. | 33 // This class processes proxy resolution requests for Chrome OS clients. |
| 34 // It processes proxy resolution requests for ChromeOS clients. | |
| 35 // | 34 // |
| 36 // The following method is exported: | 35 // The following method is exported: |
| 37 // | 36 // |
| 38 // Interface: org.chromium.LibCrosServiceInterface (kLibCrosServiceInterface) | 37 // Interface: org.chromium.NetworkProxyServiceInterface |
| 39 // Method: ResolveNetworkProxy (kResolveNetworkProxy) | 38 // (kNetworkProxyServiceInterface) |
| 39 // Method: ResolveProxy (kNetworkProxyServiceResolveProxyMethod) |
| 40 // Parameters: string:source_url | 40 // Parameters: string:source_url |
| 41 // string:signal_interface (optional) | |
| 42 // string:signal_name (optional) | |
| 43 // | 41 // |
| 44 // Resolves the proxy for |source_url|. If |signal_interface| and | 42 // Resolves the proxy for |source_url| and returns proxy information via an |
| 45 // |signal_name| are supplied, returns an empty reply immediately and | 43 // asynchronous response containing two values: |
| 46 // asynchronously emits a D-Bus signal to the requested destination. | |
| 47 // Otherwise, returns proxy information an asynchronous response without | |
| 48 // emitting a signal. | |
| 49 // | 44 // |
| 50 // The signal (if requested) will contain three values: | |
| 51 // - string:source_url - requested source URL. | |
| 52 // - string:proxy_info - proxy info for the source URL in PAC format | 45 // - string:proxy_info - proxy info for the source URL in PAC format |
| 53 // like "PROXY cache.example.com:12345" | 46 // like "PROXY cache.example.com:12345" |
| 54 // - string:error_message - error message. Empty if successful. | 47 // - string:error_message - error message. Empty if successful. |
| 55 // | |
| 56 // The method call response (if requested) will contain just two values: | |
| 57 // - string:proxy_info - proxy info for the source URL in PAC format | |
| 58 // like "PROXY cache.example.com:12345" | |
| 59 // - string:error_message - error message. Empty if successful. | |
| 60 // | 48 // |
| 61 // This service can be manually tested using dbus-send: | 49 // This service can be manually tested using dbus-send: |
| 62 // | 50 // |
| 63 // % dbus-send --system --type=method_call --print-reply | 51 // % dbus-send --system --type=method_call --print-reply |
| 64 // --dest=org.chromium.LibCrosService | 52 // --dest=org.chromium.NetworkProxyService |
| 65 // /org/chromium/LibCrosService | 53 // /org/chromium/NetworkProxyService |
| 66 // org.chromium.LibCrosServiceInterface.ResolveNetworkProxy | 54 // org.chromium.NetworkProxyServiceInterface.ResolveProxy |
| 67 // string:https://www.google.com/ | 55 // string:https://www.google.com/ |
| 68 // | 56 // |
| 69 class CHROMEOS_EXPORT ProxyResolutionServiceProvider | 57 class CHROMEOS_EXPORT ProxyResolutionServiceProvider |
| 70 : public CrosDBusService::ServiceProviderInterface { | 58 : public CrosDBusService::ServiceProviderInterface { |
| 71 public: | 59 public: |
| 72 // Delegate interface providing additional resources to | 60 // Delegate interface providing additional resources to |
| 73 // ProxyResolutionServiceProvider. | 61 // ProxyResolutionServiceProvider. |
| 74 class CHROMEOS_EXPORT Delegate { | 62 class CHROMEOS_EXPORT Delegate { |
| 75 public: | 63 public: |
| 76 virtual ~Delegate() {} | 64 virtual ~Delegate() {} |
| 77 | 65 |
| 78 // Returns the request context used to perform proxy resolution. | 66 // Returns the request context used to perform proxy resolution. |
| 79 // Always called on UI thread. | 67 // Always called on UI thread. |
| 80 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; | 68 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; |
| 81 }; | 69 }; |
| 82 | 70 |
| 83 ProxyResolutionServiceProvider(const std::string& dbus_interface, | 71 explicit ProxyResolutionServiceProvider(std::unique_ptr<Delegate> delegate); |
| 84 const std::string& dbus_method_name, | |
| 85 std::unique_ptr<Delegate> delegate); | |
| 86 ~ProxyResolutionServiceProvider() override; | 72 ~ProxyResolutionServiceProvider() override; |
| 87 | 73 |
| 88 // CrosDBusService::ServiceProviderInterface: | 74 // CrosDBusService::ServiceProviderInterface: |
| 89 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; | 75 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; |
| 90 | 76 |
| 91 private: | 77 private: |
| 92 // Data used for a single proxy resolution. | 78 // Data used for a single proxy resolution. |
| 93 struct Request; | 79 struct Request; |
| 94 | 80 |
| 95 // Returns true if called on |origin_thread_|. | 81 // Returns true if called on |origin_thread_|. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 static void OnResolutionComplete( | 110 static void OnResolutionComplete( |
| 125 std::unique_ptr<Request> request, | 111 std::unique_ptr<Request> request, |
| 126 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, | 112 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, |
| 127 NotifyCallback notify_callback, | 113 NotifyCallback notify_callback, |
| 128 int result); | 114 int result); |
| 129 | 115 |
| 130 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy | 116 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy |
| 131 // information to the client over D-Bus. | 117 // information to the client over D-Bus. |
| 132 void NotifyProxyResolved(std::unique_ptr<Request> request); | 118 void NotifyProxyResolved(std::unique_ptr<Request> request); |
| 133 | 119 |
| 134 const std::string dbus_interface_; | |
| 135 const std::string dbus_method_name_; | |
| 136 std::unique_ptr<Delegate> delegate_; | 120 std::unique_ptr<Delegate> delegate_; |
| 137 scoped_refptr<dbus::ExportedObject> exported_object_; | 121 scoped_refptr<dbus::ExportedObject> exported_object_; |
| 138 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; | 122 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; |
| 139 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; | 123 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; |
| 140 | 124 |
| 141 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); | 125 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); |
| 142 }; | 126 }; |
| 143 | 127 |
| 144 } // namespace chromeos | 128 } // namespace chromeos |
| 145 | 129 |
| 146 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 130 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| OLD | NEW |