| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Called when ResolveProxy() is exported as a D-Bus method. | 96 // Called when ResolveProxy() is exported as a D-Bus method. |
| 97 void OnExported(const std::string& interface_name, | 97 void OnExported(const std::string& interface_name, |
| 98 const std::string& method_name, | 98 const std::string& method_name, |
| 99 bool success); | 99 bool success); |
| 100 | 100 |
| 101 // Callback invoked when Chrome OS clients send network proxy resolution | 101 // Callback invoked when Chrome OS clients send network proxy resolution |
| 102 // requests to the service. Called on UI thread. | 102 // requests to the service. Called on UI thread. |
| 103 void ResolveProxy(dbus::MethodCall* method_call, | 103 void ResolveProxy(dbus::MethodCall* method_call, |
| 104 dbus::ExportedObject::ResponseSender response_sender); | 104 dbus::ExportedObject::ResponseSender response_sender); |
| 105 | 105 |
| 106 // Callback passed to network thread static methods to run |
| 107 // NotifyProxyResolved() on |origin_thread_|. This callback can be bound to a |
| 108 // WeakPtr from |weak_ptr_factory_| (since the pointer will be dereferenced on |
| 109 // |origin_thread_|), but the network methods can't (since WeakPtr disallows |
| 110 // use on threads besides the one where it was created) and are static as a |
| 111 // result. |
| 112 using NotifyCallback = base::Callback<void(std::unique_ptr<Request>)>; |
| 113 |
| 106 // Helper method for ResolveProxy() that runs on network thread. | 114 // Helper method for ResolveProxy() that runs on network thread. |
| 107 void ResolveProxyOnNetworkThread(std::unique_ptr<Request> request); | 115 static void ResolveProxyOnNetworkThread( |
| 116 std::unique_ptr<Request> request, |
| 117 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, |
| 118 NotifyCallback notify_callback); |
| 108 | 119 |
| 109 // Callback on network thread for when net::ProxyService::ResolveProxy() | 120 // Callback on network thread for when net::ProxyService::ResolveProxy() |
| 110 // completes, synchronously or asynchronously. | 121 // completes, synchronously or asynchronously. |
| 111 void OnResolutionComplete(std::unique_ptr<Request> request, int result); | 122 static void OnResolutionComplete( |
| 123 std::unique_ptr<Request> request, |
| 124 scoped_refptr<base::SingleThreadTaskRunner> notify_thread, |
| 125 NotifyCallback notify_callback, |
| 126 int result); |
| 112 | 127 |
| 113 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy | 128 // Called on UI thread from OnResolutionComplete() to pass the resolved proxy |
| 114 // information to the client over D-Bus. | 129 // information to the client over D-Bus. |
| 115 void NotifyProxyResolved(std::unique_ptr<Request> request); | 130 void NotifyProxyResolved(std::unique_ptr<Request> request); |
| 116 | 131 |
| 117 std::unique_ptr<Delegate> delegate_; | 132 std::unique_ptr<Delegate> delegate_; |
| 118 scoped_refptr<dbus::ExportedObject> exported_object_; | 133 scoped_refptr<dbus::ExportedObject> exported_object_; |
| 119 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; | 134 scoped_refptr<base::SingleThreadTaskRunner> origin_thread_; |
| 120 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; | 135 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; |
| 121 | 136 |
| 122 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); | 137 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); |
| 123 }; | 138 }; |
| 124 | 139 |
| 125 } // namespace chromeos | 140 } // namespace chromeos |
| 126 | 141 |
| 127 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 142 #endif // CHROMEOS_DBUS_SERVICES_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| OLD | NEW |