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

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

Issue 4222005: Turn on file access checks on Win. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Second try Created 10 years, 1 month 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
« no previous file with comments | « net/base/ssl_config_service_win.cc ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "net/proxy/proxy_config_service_win.h" 5 #include "net/proxy/proxy_config_service_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <winhttp.h> 8 #include <winhttp.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "base/string_tokenizer.h" 12 #include "base/string_tokenizer.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
15 #include "base/thread_restrictions.h"
15 #include "base/win/registry.h" 16 #include "base/win/registry.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/proxy/proxy_config.h" 18 #include "net/proxy/proxy_config.h"
18 19
19 #pragma comment(lib, "winhttp.lib") 20 #pragma comment(lib, "winhttp.lib")
20 21
21 namespace net { 22 namespace net {
22 23
23 namespace { 24 namespace {
24 25
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 base::ObjectWatcher watcher_; 66 base::ObjectWatcher watcher_;
66 }; 67 };
67 68
68 ProxyConfigServiceWin::ProxyConfigServiceWin() 69 ProxyConfigServiceWin::ProxyConfigServiceWin()
69 : PollingProxyConfigService( 70 : PollingProxyConfigService(
70 base::TimeDelta::FromSeconds(kPollIntervalSec), 71 base::TimeDelta::FromSeconds(kPollIntervalSec),
71 &ProxyConfigServiceWin::GetCurrentProxyConfig) { 72 &ProxyConfigServiceWin::GetCurrentProxyConfig) {
72 } 73 }
73 74
74 ProxyConfigServiceWin::~ProxyConfigServiceWin() { 75 ProxyConfigServiceWin::~ProxyConfigServiceWin() {
76 // The registry functions below will end up going to disk. Do this on another
77 // thread to avoid slowing the IO thread. http://crbug.com/61453
78 base::ThreadRestrictions::ScopedAllowIO allow_io;
75 STLDeleteElements(&keys_to_watch_); 79 STLDeleteElements(&keys_to_watch_);
76 } 80 }
77 81
78 void ProxyConfigServiceWin::AddObserver(Observer* observer) { 82 void ProxyConfigServiceWin::AddObserver(Observer* observer) {
79 // Lazily-initialize our registry watcher. 83 // Lazily-initialize our registry watcher.
80 StartWatchingRegistryForChanges(); 84 StartWatchingRegistryForChanges();
81 85
82 // Let the super-class do its work now. 86 // Let the super-class do its work now.
83 PollingProxyConfigService::AddObserver(observer); 87 PollingProxyConfigService::AddObserver(observer);
84 } 88 }
85 89
86 void ProxyConfigServiceWin::StartWatchingRegistryForChanges() { 90 void ProxyConfigServiceWin::StartWatchingRegistryForChanges() {
87 if (!keys_to_watch_.empty()) 91 if (!keys_to_watch_.empty())
88 return; // Already initialized. 92 return; // Already initialized.
89 93
94 // The registry functions below will end up going to disk. Do this on another
95 // thread to avoid slowing the IO thread. http://crbug.com/61453
96 base::ThreadRestrictions::ScopedAllowIO allow_io;
97
90 // There are a number of different places where proxy settings can live 98 // There are a number of different places where proxy settings can live
91 // in the registry. In some cases it appears in a binary value, in other 99 // in the registry. In some cases it appears in a binary value, in other
92 // cases string values. Furthermore winhttp and wininet appear to have 100 // cases string values. Furthermore winhttp and wininet appear to have
93 // separate stores, and proxy settings can be configured per-machine 101 // separate stores, and proxy settings can be configured per-machine
94 // or per-user. 102 // or per-user.
95 // 103 //
96 // This function is probably not exhaustive in the registry locations it 104 // This function is probably not exhaustive in the registry locations it
97 // watches for changes, however it should catch the majority of the 105 // watches for changes, however it should catch the majority of the
98 // cases. In case we have missed some less common triggers (likely), we 106 // cases. In case we have missed some less common triggers (likely), we
99 // will catch them during the periodic (10 second) polling, so things 107 // will catch them during the periodic (10 second) polling, so things
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 while (proxy_server_bypass_list.GetNext()) { 183 while (proxy_server_bypass_list.GetNext()) {
176 std::string bypass_url_domain = proxy_server_bypass_list.token(); 184 std::string bypass_url_domain = proxy_server_bypass_list.token();
177 config->proxy_rules().bypass_rules.AddRuleFromString(bypass_url_domain); 185 config->proxy_rules().bypass_rules.AddRuleFromString(bypass_url_domain);
178 } 186 }
179 } 187 }
180 if (ie_config.lpszAutoConfigUrl) 188 if (ie_config.lpszAutoConfigUrl)
181 config->set_pac_url(GURL(ie_config.lpszAutoConfigUrl)); 189 config->set_pac_url(GURL(ie_config.lpszAutoConfigUrl));
182 } 190 }
183 191
184 } // namespace net 192 } // namespace net
OLDNEW
« no previous file with comments | « net/base/ssl_config_service_win.cc ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698