Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / net / proxy / proxy_config_service_android.h
blob3ddbaebe78e9ead4b3e73567bbb7a74c784f587e
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.
5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
8 #include <string>
10 #include "base/android/jni_android.h"
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "net/base/net_export.h"
16 #include "net/proxy/proxy_config_service.h"
18 namespace base {
19 class SequencedTaskRunner;
22 namespace net {
24 class ProxyConfig;
26 class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService {
27 public:
28 // Callback that returns the value of the property identified by the provided
29 // key. If it was not found, an empty string is returned. Note that this
30 // interface does not let you distinguish an empty property from a
31 // non-existing property. This callback is invoked on the JNI thread.
32 typedef base::Callback<std::string (const std::string& property)>
33 GetPropertyCallback;
35 // Separate class whose instance is owned by the Delegate class implemented in
36 // the .cc file.
37 class JNIDelegate {
38 public:
39 virtual ~JNIDelegate() {}
41 // Called from Java (on JNI thread) to signal that the proxy settings have
42 // changed.
43 virtual void ProxySettingsChanged(JNIEnv*, jobject) = 0;
46 ProxyConfigServiceAndroid(base::SequencedTaskRunner* network_task_runner,
47 base::SequencedTaskRunner* jni_task_runner);
49 virtual ~ProxyConfigServiceAndroid();
51 // Register JNI bindings.
52 static bool Register(JNIEnv* env);
54 // ProxyConfigService:
55 // Called only on the network thread.
56 virtual void AddObserver(Observer* observer) OVERRIDE;
57 virtual void RemoveObserver(Observer* observer) OVERRIDE;
58 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) OVERRIDE;
60 private:
61 friend class ProxyConfigServiceAndroidTestBase;
62 class Delegate;
64 // For tests.
65 ProxyConfigServiceAndroid(base::SequencedTaskRunner* network_task_runner,
66 base::SequencedTaskRunner* jni_task_runner,
67 GetPropertyCallback get_property_callback);
69 // For tests.
70 void ProxySettingsChanged();
72 scoped_refptr<Delegate> delegate_;
74 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid);
77 } // namespace net
79 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_