OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 17 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
| 18 #include "dbus/exported_object.h" |
18 | 19 |
19 namespace dbus { | 20 namespace dbus { |
20 class ExportedObject; | |
21 class MethodCall; | 21 class MethodCall; |
22 class Response; | 22 class Response; |
23 } | 23 } |
24 | 24 |
25 namespace chromeos { | 25 namespace chromeos { |
26 | 26 |
27 class ProxyResolverInterface; | 27 class ProxyResolverInterface; |
28 | 28 |
29 // This class provides proxy resolution service for CrosDBusService. | 29 // This class provides proxy resolution service for CrosDBusService. |
30 // It processes proxy resolution requests for ChromeOS clients. | 30 // It processes proxy resolution requests for ChromeOS clients. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Called from ExportedObject, when ResolveProxyHandler() is exported as | 98 // Called from ExportedObject, when ResolveProxyHandler() is exported as |
99 // a D-Bus method, or failed to be exported. | 99 // a D-Bus method, or failed to be exported. |
100 void OnExported(const std::string& interface_name, | 100 void OnExported(const std::string& interface_name, |
101 const std::string& method_name, | 101 const std::string& method_name, |
102 bool success); | 102 bool success); |
103 | 103 |
104 // Callback to be invoked when ChromeOS clients send network proxy | 104 // Callback to be invoked when ChromeOS clients send network proxy |
105 // resolution requests to the service running in chrome executable. | 105 // resolution requests to the service running in chrome executable. |
106 // Called on UI thread from dbus request. | 106 // Called on UI thread from dbus request. |
107 dbus::Response* ResolveProxyHandler(dbus::MethodCall* method_call); | 107 void ResolveProxyHandler(dbus::MethodCall* method_call, |
| 108 dbus::ExportedObject::ResponseSender response_sender); |
108 | 109 |
109 // Calls ResolveProxyHandler() if weak_ptr is not NULL. Used to ensure a | 110 // Calls ResolveProxyHandler() if weak_ptr is not NULL. Used to ensure a |
110 // safe shutdown. | 111 // safe shutdown. |
111 static dbus::Response* CallResolveProxyHandler( | 112 static void CallResolveProxyHandler( |
112 base::WeakPtr<ProxyResolutionServiceProvider> weak_ptr, | 113 base::WeakPtr<ProxyResolutionServiceProvider> weak_ptr, |
113 dbus::MethodCall* method_call); | 114 dbus::MethodCall* method_call, |
| 115 dbus::ExportedObject::ResponseSender response_sender); |
114 | 116 |
115 // Returns true if the current thread is on the origin thread. | 117 // Returns true if the current thread is on the origin thread. |
116 bool OnOriginThread(); | 118 bool OnOriginThread(); |
117 | 119 |
118 scoped_refptr<dbus::ExportedObject> exported_object_; | 120 scoped_refptr<dbus::ExportedObject> exported_object_; |
119 scoped_ptr<ProxyResolverInterface> resolver_; | 121 scoped_ptr<ProxyResolverInterface> resolver_; |
120 base::PlatformThreadId origin_thread_id_; | 122 base::PlatformThreadId origin_thread_id_; |
121 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; | 123 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; |
122 | 124 |
123 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); | 125 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); |
(...skipping 16 matching lines...) Expand all Loading... |
140 const std::string& signal_interface, | 142 const std::string& signal_interface, |
141 const std::string& signal_name, | 143 const std::string& signal_name, |
142 scoped_refptr<dbus::ExportedObject> exported_object) = 0; | 144 scoped_refptr<dbus::ExportedObject> exported_object) = 0; |
143 | 145 |
144 virtual ~ProxyResolverInterface(); | 146 virtual ~ProxyResolverInterface(); |
145 }; | 147 }; |
146 | 148 |
147 } // namespace chromeos | 149 } // namespace chromeos |
148 | 150 |
149 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 151 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
OLD | NEW |