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

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: Add proxy_test_cases.py Created 8 years, 8 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 "base/android/scoped_java_ref.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/ref_counted.h"
Ryan Sleevi 2012/04/24 18:20:04 nit: Make sure the headers are sorted
Philippe 2012/05/09 11:48:39 Done.
12 #include "base/observer_list.h"
13 #include "base/string_piece.h"
14 #include "base/synchronization/lock.h"
15 #include "net/base/net_export.h"
16 #include "net/proxy/proxy_config.h"
17 #include "net/proxy/proxy_config_service.h"
18
19 #include <string>
Ryan Sleevi 2012/04/24 18:20:04 nit: C++ system headers should appear before any C
Philippe 2012/05/09 11:48:39 Done.
20
21 namespace base {
22 class MessageLoopProxy;
23 }
24
25 namespace net {
26
27 class NET_EXPORT ProxyConfigServiceAndroid : public ProxyConfigService {
28 public:
29 // Delegate abstracts access to the platform.
30 // Owned by ProxyConfigServiceAndroid.
31 class Delegate {
32 public:
33 virtual ~Delegate() {}
34 virtual void Start(ProxyConfigServiceAndroid* service) = 0;
35 virtual void Stop() = 0;
36 virtual std::string GetProperty(const std::string& property) = 0;
37 };
38
39 ProxyConfigServiceAndroid(); // Default
40 ProxyConfigServiceAndroid(Delegate* delegate); // For tests; takes ownership.
Ryan Sleevi 2012/04/24 18:20:04 nit: explicit ProxyConfigServiceAndroid(Delegate*
Philippe 2012/05/09 11:48:39 Done.
41 virtual ~ProxyConfigServiceAndroid();
42
43 // Register JNI bindings.
44 static bool Init(JNIEnv* env);
45
46 // ProxyConfigService:
47 virtual void AddObserver(Observer* observer) OVERRIDE;
48 virtual void RemoveObserver(Observer* observer) OVERRIDE;
49 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) OVERRIDE;
50
51 // Called from the platform on any thread to signal that proxy settings have
52 // changed. AddObserver() must have been called at least once before.
Ryan Sleevi 2012/04/24 18:20:04 I must admit, I'm not sure your threading guarante
Philippe 2012/05/09 11:48:39 This method is actually called from the Java side
53 void ProxySettingsChanged();
54
55 // Called from Java to signal that the proxy settings have changed.
56 void ProxySettingsChanged(JNIEnv*, jobject) { ProxySettingsChanged(); }
57
58 private:
59 class NotifyTask;
60
61 void ProxySettingsChangedCallback();
62 void CancelNotifyTask();
63 void ClearNotifyTask();
64 bool OnObserverThread();
65 void AssignObserverThread();
66
67 // Accessed by the constructor, and from then on from the Observer thread.
68 scoped_ptr<Delegate> delegate_;
69 ObserverList<Observer> observers_;
70
71
Ryan Sleevi 2012/04/24 18:20:04 nit: Delete extra line
Philippe 2012/05/09 11:48:39 Done.
72 base::Lock notify_task_lock_;
73 NotifyTask* notify_task_; // Accessed from any thread, guarded by lock_.
Ryan Sleevi 2012/04/24 18:20:04 Using Locks, particularly for threading, is genera
Philippe 2012/05/09 11:48:39 NotifyTask was mainly used to handle the case wher
74
75 // The thread that this object lives on; set on first call to AddObserver().
76 // Notifications from the platform (ProxySettingsChanged) will be bounced
77 // over to this thread before calling back to the Observer. All other
78 // methods should be called on this thread.
Ryan Sleevi 2012/04/24 18:20:04 This behaviour strikes me as a little surprising,
Philippe 2012/05/09 11:48:39 The message loop proxy is now injected through the
79 scoped_refptr<base::MessageLoopProxy> observer_loop_;
80 };
81
82 } // namespace net
83
84 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698