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

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

Issue 10796019: [net/dns] Retry reading config in DnsConfigServiceWin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | no next file » | 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 20 matching lines...) Expand all
31 #include "net/dns/serial_worker.h" 31 #include "net/dns/serial_worker.h"
32 32
33 #pragma comment(lib, "iphlpapi.lib") 33 #pragma comment(lib, "iphlpapi.lib")
34 34
35 namespace net { 35 namespace net {
36 36
37 namespace internal { 37 namespace internal {
38 38
39 namespace { 39 namespace {
40 40
41 // Interval between retries to parse config. Used only until parsing succeeds.
42 const int kRetryIntervalSeconds = 5;
43
41 const wchar_t* const kPrimaryDnsSuffixPath = 44 const wchar_t* const kPrimaryDnsSuffixPath =
42 L"SOFTWARE\\Policies\\Microsoft\\System\\DNSClient"; 45 L"SOFTWARE\\Policies\\Microsoft\\System\\DNSClient";
43 46
44 enum HostsParseWinResult { 47 enum HostsParseWinResult {
45 HOSTS_PARSE_WIN_OK = 0, 48 HOSTS_PARSE_WIN_OK = 0,
46 HOSTS_PARSE_WIN_UNREADABLE_HOSTS_FILE, 49 HOSTS_PARSE_WIN_UNREADABLE_HOSTS_FILE,
47 HOSTS_PARSE_WIN_COMPUTER_NAME_FAILED, 50 HOSTS_PARSE_WIN_COMPUTER_NAME_FAILED,
48 HOSTS_PARSE_WIN_IPHELPER_FAILED, 51 HOSTS_PARSE_WIN_IPHELPER_FAILED,
49 HOSTS_PARSE_WIN_BAD_ADDRESS, 52 HOSTS_PARSE_WIN_BAD_ADDRESS,
50 HOSTS_PARSE_WIN_MAX // Bounding values for enumeration. 53 HOSTS_PARSE_WIN_MAX // Bounding values for enumeration.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 base::TimeTicks::Now() - start_time); 475 base::TimeTicks::Now() - start_time);
473 } 476 }
474 477
475 virtual void OnWorkFinished() OVERRIDE { 478 virtual void OnWorkFinished() OVERRIDE {
476 DCHECK(loop()->BelongsToCurrentThread()); 479 DCHECK(loop()->BelongsToCurrentThread());
477 DCHECK(!IsCancelled()); 480 DCHECK(!IsCancelled());
478 if (success_) { 481 if (success_) {
479 service_->OnConfigRead(dns_config_); 482 service_->OnConfigRead(dns_config_);
480 } else { 483 } else {
481 LOG(WARNING) << "Failed to read DnsConfig."; 484 LOG(WARNING) << "Failed to read DnsConfig.";
485 // Try again in a while in case DnsConfigWatcher missed the signal.
486 MessageLoop::current()->PostDelayedTask(
487 FROM_HERE,
488 base::Bind(&ConfigReader::WorkNow, this),
489 base::TimeDelta::FromSeconds(kRetryIntervalSeconds));
482 } 490 }
483 } 491 }
484 492
485 DnsConfigServiceWin* service_; 493 DnsConfigServiceWin* service_;
486 // Written in DoRead(), read in OnReadFinished(). No locking required. 494 // Written in DoWork(), read in OnWorkFinished(). No locking required.
487 DnsConfig dns_config_; 495 DnsConfig dns_config_;
488 bool success_; 496 bool success_;
489 }; 497 };
490 498
491 // Reads hosts from HOSTS file and fills in localhost and local computer name if 499 // Reads hosts from HOSTS file and fills in localhost and local computer name if
492 // necessary. All work performed on WorkerPool. 500 // necessary. All work performed on WorkerPool.
493 class DnsConfigServiceWin::HostsReader : public SerialWorker { 501 class DnsConfigServiceWin::HostsReader : public SerialWorker {
494 public: 502 public:
495 explicit HostsReader(DnsConfigServiceWin* service) 503 explicit HostsReader(DnsConfigServiceWin* service)
496 : path_(GetHostsPath()), 504 : path_(GetHostsPath()),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 585
578 } // namespace internal 586 } // namespace internal
579 587
580 // static 588 // static
581 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { 589 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
582 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin()); 590 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin());
583 } 591 }
584 592
585 } // namespace net 593 } // namespace net
586 594
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698