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

Side by Side Diff: net/dns/dns_config_service_win.cc

Issue 9369045: [net] HostResolverImpl + DnsTransaction + DnsConfigService = Asynchronous DNS ready for experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Denitted. Created 8 years, 10 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
« no previous file with comments | « net/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_response.h » ('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) 2012 The Chromium Authors. All rights reserved. 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 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/dns/dns_config_service_win.h" 5 #include "net/dns/dns_config_service_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // up watches requires IO loop. 300 // up watches requires IO loop.
301 class DnsConfigServiceWin::ConfigReader : public SerialWorker { 301 class DnsConfigServiceWin::ConfigReader : public SerialWorker {
302 public: 302 public:
303 explicit ConfigReader(DnsConfigServiceWin* service) 303 explicit ConfigReader(DnsConfigServiceWin* service)
304 : service_(service), 304 : service_(service),
305 success_(false) {} 305 success_(false) {}
306 306
307 bool StartWatch() { 307 bool StartWatch() {
308 DCHECK(loop()->BelongsToCurrentThread()); 308 DCHECK(loop()->BelongsToCurrentThread());
309 309
310 // This is done only once per lifetime so open the keys on this thread.
311 base::ThreadRestrictions::ScopedAllowIO allow_io;
312
313 base::Closure callback = base::Bind(&SerialWorker::WorkNow, 310 base::Closure callback = base::Bind(&SerialWorker::WorkNow,
314 base::Unretained(this)); 311 base::Unretained(this));
315 312
316 // DNS suffix search list and devolution can be configured via group 313 // DNS suffix search list and devolution can be configured via group
317 // policy which sets this registry key. If the key is missing, the policy 314 // policy which sets this registry key. If the key is missing, the policy
318 // does not apply, and the DNS client uses Tcpip and Dnscache settings. 315 // does not apply, and the DNS client uses Tcpip and Dnscache settings.
319 // If a policy is installed, DnsConfigService will need to be restarted. 316 // If a policy is installed, DnsConfigService will need to be restarted.
320 // BUG=99509 317 // BUG=99509
321 policy_watcher_.StartWatch( 318 policy_watcher_.StartWatch(
322 L"SOFTWARE\\Policies\\Microsoft\\Windows NT\\DNSClient", 319 L"SOFTWARE\\Policies\\Microsoft\\Windows NT\\DNSClient",
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 : config_reader_(new ConfigReader(this)), 438 : config_reader_(new ConfigReader(this)),
442 hosts_watcher_(new WatchingFileReader()) {} 439 hosts_watcher_(new WatchingFileReader()) {}
443 440
444 DnsConfigServiceWin::~DnsConfigServiceWin() { 441 DnsConfigServiceWin::~DnsConfigServiceWin() {
445 DCHECK(CalledOnValidThread()); 442 DCHECK(CalledOnValidThread());
446 config_reader_->Cancel(); 443 config_reader_->Cancel();
447 } 444 }
448 445
449 void DnsConfigServiceWin::Watch() { 446 void DnsConfigServiceWin::Watch() {
450 DCHECK(CalledOnValidThread()); 447 DCHECK(CalledOnValidThread());
448
449 // This is done only once per lifetime so open the keys and file watcher
450 // handles on this thread.
451 // TODO(szym): Should/can this be avoided? http://crbug.com/114223
452 base::ThreadRestrictions::ScopedAllowIO allow_io;
453
451 bool started = config_reader_->StartWatch(); 454 bool started = config_reader_->StartWatch();
452 // TODO(szym): handle possible failure 455 // TODO(szym): handle possible failure
453 DCHECK(started); 456 DCHECK(started);
454 457
455 TCHAR buffer[MAX_PATH]; 458 TCHAR buffer[MAX_PATH];
456 UINT rc = GetSystemDirectory(buffer, MAX_PATH); 459 UINT rc = GetSystemDirectory(buffer, MAX_PATH);
457 DCHECK(0 < rc && rc < MAX_PATH); 460 DCHECK(0 < rc && rc < MAX_PATH);
458 FilePath hosts_path = FilePath(buffer). 461 FilePath hosts_path = FilePath(buffer).
459 Append(FILE_PATH_LITERAL("drivers\\etc\\hosts")); 462 Append(FILE_PATH_LITERAL("drivers\\etc\\hosts"));
460 hosts_watcher_->StartWatch(hosts_path, new DnsHostsReader(hosts_path, this)); 463 hosts_watcher_->StartWatch(hosts_path, new DnsHostsReader(hosts_path, this));
461 } 464 }
462 465
463 // static 466 // static
464 DnsConfigService* DnsConfigService::CreateSystemService() { 467 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
465 return new DnsConfigServiceWin(); 468 return scoped_ptr<DnsConfigService>(new DnsConfigServiceWin());
466 } 469 }
467 470
468 } // namespace net 471 } // namespace net
469 472
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_posix_unittest.cc ('k') | net/dns/dns_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698