| 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" | |
| 19 | 18 |
| 20 namespace dbus { | 19 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 void ResolveProxyHandler(dbus::MethodCall* method_call, | 107 dbus::Response* ResolveProxyHandler(dbus::MethodCall* method_call); |
| 108 dbus::ExportedObject::ResponseSender response_sender); | |
| 109 | 108 |
| 110 // Calls ResolveProxyHandler() if weak_ptr is not NULL. Used to ensure a | 109 // Calls ResolveProxyHandler() if weak_ptr is not NULL. Used to ensure a |
| 111 // safe shutdown. | 110 // safe shutdown. |
| 112 static void CallResolveProxyHandler( | 111 static dbus::Response* CallResolveProxyHandler( |
| 113 base::WeakPtr<ProxyResolutionServiceProvider> weak_ptr, | 112 base::WeakPtr<ProxyResolutionServiceProvider> weak_ptr, |
| 114 dbus::MethodCall* method_call, | 113 dbus::MethodCall* method_call); |
| 115 dbus::ExportedObject::ResponseSender response_sender); | |
| 116 | 114 |
| 117 // Returns true if the current thread is on the origin thread. | 115 // Returns true if the current thread is on the origin thread. |
| 118 bool OnOriginThread(); | 116 bool OnOriginThread(); |
| 119 | 117 |
| 120 scoped_refptr<dbus::ExportedObject> exported_object_; | 118 scoped_refptr<dbus::ExportedObject> exported_object_; |
| 121 scoped_ptr<ProxyResolverInterface> resolver_; | 119 scoped_ptr<ProxyResolverInterface> resolver_; |
| 122 base::PlatformThreadId origin_thread_id_; | 120 base::PlatformThreadId origin_thread_id_; |
| 123 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; | 121 base::WeakPtrFactory<ProxyResolutionServiceProvider> weak_ptr_factory_; |
| 124 | 122 |
| 125 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); | 123 DISALLOW_COPY_AND_ASSIGN(ProxyResolutionServiceProvider); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 142 const std::string& signal_interface, | 140 const std::string& signal_interface, |
| 143 const std::string& signal_name, | 141 const std::string& signal_name, |
| 144 scoped_refptr<dbus::ExportedObject> exported_object) = 0; | 142 scoped_refptr<dbus::ExportedObject> exported_object) = 0; |
| 145 | 143 |
| 146 virtual ~ProxyResolverInterface(); | 144 virtual ~ProxyResolverInterface(); |
| 147 }; | 145 }; |
| 148 | 146 |
| 149 } // namespace chromeos | 147 } // namespace chromeos |
| 150 | 148 |
| 151 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ | 149 #endif // CHROME_BROWSER_CHROMEOS_DBUS_PROXY_RESOLUTION_SERVICE_PROVIDER_H_ |
| OLD | NEW |