OLD | NEW |
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 "chrome/browser/net/dns_master.h" | 5 #include "chrome/browser/net/dns_master.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/histogram.h" | 12 #include "base/histogram.h" |
13 #include "base/stats_counters.h" | 13 #include "base/stats_counters.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/chrome_thread.h" | 16 #include "chrome/browser/chrome_thread.h" |
17 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_log.h" |
21 | 22 |
22 using base::TimeDelta; | 23 using base::TimeDelta; |
23 | 24 |
24 namespace chrome_browser_net { | 25 namespace chrome_browser_net { |
25 | 26 |
26 class DnsMaster::LookupRequest { | 27 class DnsMaster::LookupRequest { |
27 public: | 28 public: |
28 LookupRequest(DnsMaster* master, | 29 LookupRequest(DnsMaster* master, |
29 net::HostResolver* host_resolver, | 30 net::HostResolver* host_resolver, |
30 const std::string& hostname) | 31 const std::string& hostname) |
(...skipping 10 matching lines...) Expand all Loading... |
41 // anything else ==> Host was not found synchronously. | 42 // anything else ==> Host was not found synchronously. |
42 int Start() { | 43 int Start() { |
43 // Port doesn't really matter. | 44 // Port doesn't really matter. |
44 net::HostResolver::RequestInfo resolve_info(hostname_, 80); | 45 net::HostResolver::RequestInfo resolve_info(hostname_, 80); |
45 | 46 |
46 // Make a note that this is a speculative resolve request. This allows us | 47 // Make a note that this is a speculative resolve request. This allows us |
47 // to separate it from real navigations in the observer's callback, and | 48 // to separate it from real navigations in the observer's callback, and |
48 // lets the HostResolver know it can de-prioritize it. | 49 // lets the HostResolver know it can de-prioritize it. |
49 resolve_info.set_is_speculative(true); | 50 resolve_info.set_is_speculative(true); |
50 return resolver_.Resolve( | 51 return resolver_.Resolve( |
51 resolve_info, &addresses_, &net_callback_, NULL); | 52 resolve_info, &addresses_, &net_callback_, net::BoundNetLog()); |
52 } | 53 } |
53 | 54 |
54 private: | 55 private: |
55 void OnLookupFinished(int result) { | 56 void OnLookupFinished(int result) { |
56 master_->OnLookupFinished(this, hostname_, result == net::OK); | 57 master_->OnLookupFinished(this, hostname_, result == net::OK); |
57 } | 58 } |
58 | 59 |
59 // HostResolver will call us using this callback when resolution is complete. | 60 // HostResolver will call us using this callback when resolution is complete. |
60 net::CompletionCallbackImpl<LookupRequest> net_callback_; | 61 net::CompletionCallbackImpl<LookupRequest> net_callback_; |
61 | 62 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 std::string hostname(rush_queue_.front()); | 581 std::string hostname(rush_queue_.front()); |
581 rush_queue_.pop(); | 582 rush_queue_.pop(); |
582 return hostname; | 583 return hostname; |
583 } | 584 } |
584 std::string hostname(background_queue_.front()); | 585 std::string hostname(background_queue_.front()); |
585 background_queue_.pop(); | 586 background_queue_.pop(); |
586 return hostname; | 587 return hostname; |
587 } | 588 } |
588 | 589 |
589 } // namespace chrome_browser_net | 590 } // namespace chrome_browser_net |
OLD | NEW |