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/scoped_java_ref.h" | |
|
Ryan Sleevi
2012/05/14 18:00:25
nit: I don't see this being used in this header
Philippe
2012/05/15 16:12:48
Done.
| |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
|
Ryan Sleevi
2012/05/14 18:00:25
nit: nor this?
Philippe
2012/05/15 16:12:48
Done.
| |
| 14 #include "base/observer_list.h" | |
|
Ryan Sleevi
2012/05/14 18:00:25
or this
Philippe
2012/05/15 16:12:48
Indeed. It seems that I forgot to remove these inc
| |
| 15 #include "net/base/net_export.h" | |
| 16 #include "net/proxy/proxy_config.h" | |
|
Ryan Sleevi
2012/05/14 18:00:25
nit: You can forward declare net::ProxyConfig - it
Philippe
2012/05/15 16:12:48
Done.
| |
| 17 #include "net/proxy/proxy_config_service.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class SingleThreadTaskRunner; | |
| 21 } | |
| 22 | |
| 23 namespace net { | |
| 24 | |
| 25 class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService { | |
| 26 public: | |
| 27 // Delegate abstracts access to the platform. | |
| 28 // Owned by ProxyConfigServiceAndroid. | |
| 29 class Delegate { | |
| 30 public: | |
| 31 virtual ~Delegate() {} | |
| 32 | |
| 33 // Notifies the platform that the proxy config service started. The caller | |
| 34 // keeps ownership of |service|. | |
| 35 virtual void Start(ProxyConfigServiceAndroid* service) = 0; | |
| 36 virtual void Stop() = 0; | |
| 37 | |
| 38 // Returns the value of the property identified by the provided key. If it | |
| 39 // was not found, an empty string is returned. Note that this interface | |
| 40 // does not let you distinguish an empty property from a non-existing | |
| 41 // property. | |
| 42 virtual std::string GetProperty(const std::string& property) = 0; | |
| 43 }; | |
| 44 | |
| 45 ProxyConfigServiceAndroid( | |
| 46 scoped_refptr<base::SingleThreadTaskRunner> observer_runner); | |
| 47 virtual ~ProxyConfigServiceAndroid(); | |
| 48 | |
| 49 // Register JNI bindings. | |
| 50 static bool Register(JNIEnv* env); | |
| 51 | |
| 52 // ProxyConfigService: | |
| 53 // Observer-related operations must be called on the observer thread. | |
| 54 virtual void AddObserver(Observer* observer) OVERRIDE; | |
| 55 virtual void RemoveObserver(Observer* observer) OVERRIDE; | |
|
Ryan Sleevi
2012/05/14 18:00:25
BUG? AddObserver/RemoveObserver are called on the
Philippe
2012/05/15 16:12:48
I might be missing something but the observer thre
| |
| 56 | |
| 57 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) OVERRIDE; | |
| 58 | |
| 59 void ProxySettingsChanged(); | |
| 60 | |
| 61 // Called from Java to signal that the proxy settings have changed. | |
| 62 void ProxySettingsChanged(JNIEnv*, jobject) { ProxySettingsChanged(); } | |
|
Ryan Sleevi
2012/05/14 18:00:25
Avoid overloads (Line 59 & 62) - http://google-sty
Philippe
2012/05/15 16:12:48
Done.
| |
| 63 | |
| 64 private: | |
| 65 friend class ProxyConfigServiceAndroidTest; | |
| 66 | |
| 67 // For tests; takes ownership of |delegate|. | |
| 68 ProxyConfigServiceAndroid( | |
| 69 scoped_refptr<base::SingleThreadTaskRunner> observer_runner, | |
|
Ryan Sleevi
2012/05/14 18:00:25
Same here - take a naked pointer.
Philippe
2012/05/15 16:12:48
Done.
| |
| 70 Delegate* delegate); | |
| 71 | |
| 72 // Structure holding the state used by both this class and the asynchronous | |
| 73 // callback running on the observer thread. Instances of SharedState are | |
| 74 // referenced through a shared pointer so that we handle the case where | |
| 75 // ProxyConfigServiceAndroid gets deleted before the asynchronous callback | |
| 76 // (using this state) runs. | |
| 77 struct SharedState; | |
| 78 | |
| 79 // Called on observer thread. | |
| 80 static void ProxySettingsChangedCallback( | |
| 81 scoped_refptr<SharedState> callback_state); | |
|
Ryan Sleevi
2012/05/14 18:00:25
const scoped_refptr<SharedState>& callback_state
Philippe
2012/05/15 16:12:48
I might be wrong, but it seems safer in this parti
Philippe
2012/05/16 08:01:06
I was wrong. I forgot when I wrote the previous me
| |
| 82 bool OnObserverThread() const; | |
| 83 | |
| 84 const scoped_refptr<SharedState> shared_state_; | |
| 85 | |
| 86 // Task runner of the thread on which observers are notified whenever proxy | |
| 87 // settings change. | |
| 88 const scoped_refptr<base::SingleThreadTaskRunner> observer_runner_; | |
|
Ryan Sleevi
2012/05/14 18:00:25
DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid
Philippe
2012/05/15 16:12:48
Done.
| |
| 89 }; | |
| 90 | |
| 91 } // namespace net | |
| 92 | |
| 93 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_ | |
| OLD | NEW |