Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_ | |
| 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/android/jni_android.h" | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/callback_forward.h" | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "base/memory/ref_counted.h" | |
| 16 #include "net/base/net_export.h" | |
| 17 #include "net/proxy/proxy_config_service.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class SingleThreadTaskRunner; | |
| 21 } | |
| 22 | |
| 23 namespace net { | |
| 24 | |
| 25 class ProxyConfig; | |
| 26 | |
| 27 class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService { | |
| 28 public: | |
| 29 // Callback that returns the value of the property identified by the provided | |
| 30 // key. If it was not found, an empty string is returned. Note that this | |
| 31 // interface does not let you distinguish an empty property from a | |
| 32 // non-existing property. This callback is invoked on the JNI thread. | |
| 33 typedef base::Callback<std::string (const std::string& property)> | |
| 34 GetPropertyCallback; | |
| 35 | |
| 36 // Separate class whose instance is owned by the Delegate class implemented in | |
| 37 // the header. That lets us decouple ProxySettingsChanged() from | |
| 38 // ProxyConfigServiceAndroid lifecycle without exposing the Delegate here in | |
| 39 // the header. | |
|
Ryan Sleevi
2012/06/04 21:49:18
Does this second half of the comment still apply..
Philippe
2012/06/05 09:07:54
I removed the second sentence.
| |
| 40 class JNIDelegate { | |
| 41 public: | |
| 42 virtual ~JNIDelegate() {} | |
| 43 | |
| 44 // Called from Java (on JNI thread) to signal that the proxy settings have | |
| 45 // changed. | |
| 46 virtual void ProxySettingsChanged(JNIEnv*, jobject) = 0; | |
| 47 }; | |
| 48 | |
| 49 ProxyConfigServiceAndroid(base::SingleThreadTaskRunner* network_task_runner, | |
| 50 base::SingleThreadTaskRunner* jni_task_runner); | |
|
Ryan Sleevi
2012/06/04 21:49:18
Do these need to be SingleThreadTaskRunners? That
Philippe
2012/06/05 09:07:54
I was using SingleThreadTaskRunners for BelongsToC
| |
| 51 | |
| 52 virtual ~ProxyConfigServiceAndroid(); | |
| 53 | |
| 54 // Register JNI bindings. | |
| 55 static bool Register(JNIEnv* env); | |
| 56 | |
| 57 // ProxyConfigService: | |
| 58 // Called only on the network thread. | |
| 59 virtual void AddObserver(Observer* observer) OVERRIDE; | |
| 60 virtual void RemoveObserver(Observer* observer) OVERRIDE; | |
| 61 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) OVERRIDE; | |
| 62 | |
| 63 private: | |
| 64 friend class ProxyConfigServiceAndroidTestBase; | |
| 65 class Delegate; | |
| 66 | |
| 67 | |
| 68 // For tests. | |
| 69 ProxyConfigServiceAndroid(base::SingleThreadTaskRunner* network_task_runner, | |
| 70 base::SingleThreadTaskRunner* jni_task_runner, | |
| 71 GetPropertyCallback get_property_callback); | |
| 72 | |
| 73 // For tests. | |
| 74 void ProxySettingsChanged(); | |
| 75 | |
| 76 scoped_refptr<Delegate> delegate_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid); | |
| 79 }; | |
| 80 | |
| 81 } // namespace net | |
| 82 | |
| 83 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_ | |
| OLD | NEW |