Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: net/proxy/proxy_config_service_android.h

Issue 10206014: Upstream Android proxy config service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass scoped_refptr by const reference Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/memory/ref_counted.h"
14 #include "net/base/net_export.h"
15 #include "net/proxy/proxy_config_service.h"
16
17 namespace base {
18 class SingleThreadTaskRunner;
19 }
20
21 namespace net {
22
23 class ProxyConfig;
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(base::SingleThreadTaskRunner* observer_runner);
Ryan Sleevi 2012/05/19 01:26:31 explicit
Philippe 2012/05/22 15:23:05 Done. The constructor now takes two parameters.
46 virtual ~ProxyConfigServiceAndroid();
47
48 // Register JNI bindings.
49 static bool Register(JNIEnv* env);
50
51 // ProxyConfigService:
52 // Observer-related operations must be called on the observer thread.
53 virtual void AddObserver(Observer* observer) OVERRIDE;
54 virtual void RemoveObserver(Observer* observer) OVERRIDE;
55
Ryan Sleevi 2012/05/19 01:26:31 Delete this blank line, per http://www.chromium.or
Philippe 2012/05/22 15:23:05 Done.
56 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) OVERRIDE;
57
58 void ProxySettingsChangedInternal();
59
60 // Called from Java to signal that the proxy settings have changed.
61 void ProxySettingsChanged(JNIEnv*, jobject) {
62 ProxySettingsChangedInternal();
63 }
64
65 private:
66 friend class ProxyConfigServiceAndroidTest;
67
68 // For tests; takes ownership of |delegate|.
69 ProxyConfigServiceAndroid(base::SingleThreadTaskRunner* observer_runner,
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;
Ryan Sleevi 2012/05/19 01:26:31 nit: Not always consistently, but there was a big
Philippe 2012/05/22 15:23:05 Thanks for the information.
78
79 // Called on observer thread.
80 static void ProxySettingsChangedCallback(
81 const scoped_refptr<SharedState>& callback_state);
82 bool OnObserverThread() const;
83
84 scoped_refptr<SharedState> shared_state_;
85
86 // Task runner of the thread on which observers are notified whenever proxy
87 // settings change.
88 scoped_refptr<base::SingleThreadTaskRunner> observer_runner_;
89
90 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceAndroid);
91 };
92
93 } // namespace net
94
95 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698