| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // ProxyResolutionServiceProvider. | 73 // ProxyResolutionServiceProvider. |
| 74 class CHROMEOS_EXPORT Delegate { | 74 class CHROMEOS_EXPORT Delegate { |
| 75 public: | 75 public: |
| 76 virtual ~Delegate() {} | 76 virtual ~Delegate() {} |
| 77 | 77 |
| 78 // Returns the request context used to perform proxy resolution. | 78 // Returns the request context used to perform proxy resolution. |
| 79 // Always called on UI thread. | 79 // Always called on UI thread. |
| 80 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; | 80 virtual scoped_refptr<net::URLRequestContextGetter> GetRequestContext() = 0; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 explicit ProxyResolutionServiceProvider(std::unique_ptr<Delegate> delegate); | 83 ProxyResolutionServiceProvider(const std::string& dbus_interface, |
| 84 const std::string& dbus_method_name, |
| 85 std::unique_ptr<Delegate> delegate); |
| 84 ~ProxyResolutionServiceProvider() override; | 86 ~ProxyResolutionServiceProvider() override; |
| 85 | 87 |
| 86 // CrosDBusService::ServiceProviderInterface: | 88 // CrosDBusService::ServiceProviderInterface: |
| 87 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; | 89 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; |
| 88 | 90 |
| 89 private: | 91 private: |
| 90 // Data used for a single proxy resolution. | 92 // Data used for a single proxy resolution. |
| 91 struct Request; | 93 struct Request; |
| 92 | 94 |
| 93 // Returns true if called on |origin_thread_|. | 95 // Returns true if called on |origin_thread_|. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 122 static void OnResolutionComplete( | 124 static void OnResolutionComplete( |
| 123 std::unique_ptr<Request> request, | 125 std::unique_ptr<Request> request, |
| 124 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, | 126 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, |
| 125 NotifyCallback notify_callback, | 127 NotifyCallback notify_callback, |
| 126 int result); | 128 int result); |
| 127 | 129 |
| 128 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy | 130 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy |
| 129 // information to the client over D-Bus. | 131 // information to the client over D-Bus. |
| 130 void NotifyProxyResolved(std::unique_ptr<Request> request); | 132 void NotifyProxyResolved(std::unique_ptr<Request> request); |
| 131 | 133 |
| 134 const std::string dbus_interface_; |
| 135 const std::string dbus_method_name_; |
| 132 std::unique_ptr<Delegate> delegate_; | 136 std::unique_ptr<Delegate> delegate_; |
| 133 scoped_refptr<dbus::ExportedObject> exported_object_; | 137 scoped_refptr<dbus::ExportedObject> exported_object_; |
| 134 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; | 138 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; |
| 135 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; | 139 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; |
| 136 | 140 |
| 137 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); | 141 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); |
| 138 }; | 142 }; |
| 139 | 143 |
| 140 } // namespace chromeos | 144 } // namespace chromeos |
| 141 | 145 |
| 142 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 146 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| OLD | NEW |