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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « net/proxy/proxy_config_service_mac.cc ('k') | net/proxy/proxy_config_service_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_
7
8 #include <windows.h>
9 #include <winhttp.h>
10
11 #include <vector>
12
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "net/proxy/polling_proxy_config_service.h"
16
17 namespace base {
18 namespace win {
19 class RegKey;
20 }
21 } // namespace base.
22
23 namespace net {
24
25 // Implementation of ProxyConfigService that retrieves the system proxy
26 // settings.
27 //
28 // It works by calling WinHttpGetIEProxyConfigForCurrentUser() to fetch the
29 // Internet Explorer proxy settings.
30 //
31 // We use two different strategies to notice when the configuration has
32 // changed:
33 //
34 // (1) Watch the internet explorer settings registry keys for changes. When
35 // one of the registry keys pertaining to proxy settings has changed, we
36 // call WinHttpGetIEProxyConfigForCurrentUser() again to read the
37 // configuration's new value.
38 //
39 // (2) Do regular polling every 10 seconds during network activity to see if
40 // WinHttpGetIEProxyConfigForCurrentUser() returns something different.
41 //
42 // Ideally strategy (1) should be sufficient to pick up all of the changes.
43 // However we still do the regular polling as a precaution in case the
44 // implementation details of WinHttpGetIEProxyConfigForCurrentUser() ever
45 // change, or in case we got it wrong (and are not checking all possible
46 // registry dependencies).
47 class NET_EXPORT_PRIVATE ProxyConfigServiceWin
48 : public PollingProxyConfigService {
49 public:
50 ProxyConfigServiceWin();
51 virtual ~ProxyConfigServiceWin();
52
53 // Overrides a function from PollingProxyConfigService.
54 virtual void AddObserver(Observer* observer) override;
55
56 private:
57 FRIEND_TEST_ALL_PREFIXES(ProxyConfigServiceWinTest, SetFromIEConfig);
58 typedef std::vector<base::win::RegKey*> RegKeyList;
59
60 // Registers change observers on the registry keys relating to proxy settings.
61 void StartWatchingRegistryForChanges();
62
63 // Creates a new key and appends it to |keys_to_watch_|. If the key fails to
64 // be created, it is not appended to the list and we return false.
65 bool AddKeyToWatchList(HKEY rootkey, const wchar_t* subkey);
66
67 // This is called whenever one of the registry keys we are watching change.
68 void OnObjectSignaled(base::win::RegKey* key);
69
70 static void GetCurrentProxyConfig(ProxyConfig* config);
71
72 // Set |config| using the proxy configuration values of |ie_config|.
73 static void SetFromIEConfig(
74 ProxyConfig* config,
75 const WINHTTP_CURRENT_USER_IE_PROXY_CONFIG& ie_config);
76
77 RegKeyList keys_to_watch_;
78 };
79
80 } // namespace net
81
82 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_WIN_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_mac.cc ('k') | net/proxy/proxy_config_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698