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

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

Issue 6597070: Allow ProxyConfigService to report "no configuration set" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 9 years, 9 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_H_ 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_H_
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_H_ 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 namespace net { 9 namespace net {
10 10
11 class ProxyConfig; 11 class ProxyConfig;
12 12
13 // Service for watching when the proxy settings have changed. 13 // Service for watching when the proxy settings have changed.
14 class ProxyConfigService { 14 class ProxyConfigService {
15 public: 15 public:
16 // Indicates whether proxy configuration is valid, and if not, why.
17 enum ConfigAvailability {
18 // Configuration is pending, observers will be notified later.
19 CONFIG_PENDING,
20 // Configuration is present and valid.
21 CONFIG_VALID,
22 // No configuration is set, use default.
eroman 2011/03/16 01:30:00 nit: I suggest removing the "use default" comment
Mattias Nissler (ping if slow) 2011/03/16 17:40:00 Done.
23 CONFIG_UNSET
24 };
25
16 // Observer for being notified when the proxy settings have changed. 26 // Observer for being notified when the proxy settings have changed.
17 class Observer { 27 class Observer {
18 public: 28 public:
19 virtual ~Observer() {} 29 virtual ~Observer() {}
20 virtual void OnProxyConfigChanged(const ProxyConfig& config) = 0; 30 virtual void OnProxyConfigChanged(const ProxyConfig& config,
eroman 2011/03/16 01:30:00 Could you add a comment explaining that |availabil
Mattias Nissler (ping if slow) 2011/03/16 17:40:00 Done.
31 ConfigAvailability availability) = 0;
21 }; 32 };
22 33
23 virtual ~ProxyConfigService() {} 34 virtual ~ProxyConfigService() {}
24 35
25 // Adds/Removes an observer that will be called whenever the proxy 36 // Adds/Removes an observer that will be called whenever the proxy
26 // configuration has changed. 37 // configuration has changed.
27 virtual void AddObserver(Observer* observer) = 0; 38 virtual void AddObserver(Observer* observer) = 0;
28 virtual void RemoveObserver(Observer* observer) = 0; 39 virtual void RemoveObserver(Observer* observer) = 0;
29 40
30 // Gets the most recent value of the proxy configuration. Returns false if 41 // Gets the most recent value of the proxy configuration. Returns false if
eroman 2011/03/16 01:30:00 Please update these comments regarding the return
Mattias Nissler (ping if slow) 2011/03/16 17:40:00 Absolutely! Sorry for missing it. Done.
eroman 2011/03/26 00:50:30 I don't see this change in the latest pathset...
31 // it is not available yet. In the case where we returned false, it is 42 // it is not available yet. In the case where we returned false, it is
32 // guaranteed that subscribed observers will be notified of a change at 43 // guaranteed that subscribed observers will be notified of a change at
33 // some point in the future once the configuration is available. 44 // some point in the future once the configuration is available.
34 // Note that to avoid re-entrancy problems, implementations should not 45 // Note that to avoid re-entrancy problems, implementations should not
35 // dispatch any change notifications from within this function. 46 // dispatch any change notifications from within this function.
36 virtual bool GetLatestProxyConfig(ProxyConfig* config) = 0; 47 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) = 0;
37 48
38 // ProxyService will call this periodically during periods of activity. 49 // ProxyService will call this periodically during periods of activity.
39 // It can be used as a signal for polling-based implementations. 50 // It can be used as a signal for polling-based implementations.
40 // 51 //
41 // Note that this is purely used as an optimization -- polling 52 // Note that this is purely used as an optimization -- polling
42 // implementations could simply set a global timer that goes off every 53 // implementations could simply set a global timer that goes off every
43 // X seconds at which point they check for changes. However that has 54 // X seconds at which point they check for changes. However that has
44 // the disadvantage of doing continuous work even during idle periods. 55 // the disadvantage of doing continuous work even during idle periods.
45 virtual void OnLazyPoll() {} 56 virtual void OnLazyPoll() {}
46 }; 57 };
47 58
48 } // namespace net 59 } // namespace net
49 60
50 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_H_ 61 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698