OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 // A RendererNetPredictor instance is maintained for each RenderThread. | 5 // A RendererDnsPrefetch instance is maintained for each RenderThread. |
6 // URL strings are typically added to the embedded queue during rendering. | 6 // URL strings are typically added to the embedded queue during rendering. |
7 // The first addition to the queue (transitioning from empty to having | 7 // The first addition to the queue (transitioning from empty to having |
8 // some names) causes a processing task to be added to the Renderer Thread. | 8 // some names) causes a processing task to be added to the Renderer Thread. |
9 // The processing task gathers all buffered names, and send them via IPC | 9 // The processing task gathers all buffered names, and send them via IPC |
10 // to the browser, so that DNS lookups can be performed before the user attempts | 10 // to the browser, so that DNS lookups can be performed before the user attempts |
11 // to traverse a link. | 11 // to traverse a link. |
12 // This class removed some duplicates, and discards numeric IP addresss | 12 // This class removed some duplicates, and discards numeric IP addresss |
13 // (which wouldn't looked up in DNS anyway). | 13 // (which wouldn't looked up in DNS anyway). |
14 // To limit the time during the processing task (and avoid stalling the Render | 14 // To limit the time during the processing task (and avoid stalling the Render |
15 // thread), several limits are placed on how much of the queue to process. | 15 // thread), several limits are placed on how much of the queue to process. |
16 // If the processing task is not able to completely empty the queue, it | 16 // If the processing task is not able to completely empty the queue, it |
17 // schedules a future continuation of the task, and keeps the map of already | 17 // schedules a future continuation of the task, and keeps the map of already |
18 // sent names. If the entire queue is processed, then the list of "sent names" | 18 // sent names. If the entire queue is processed, then the list of "sent names" |
19 // is cleared so that future gatherings might again pass along the same names. | 19 // is cleared so that future gatherings might again pass along the same names. |
20 | 20 |
21 #ifndef COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ | 21 #ifndef COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ |
22 #define COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ | 22 #define COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ |
23 | 23 |
24 #include <map> | 24 #include <map> |
25 #include <string> | 25 #include <string> |
26 | 26 |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
28 #include "base/memory/weak_ptr.h" | 28 #include "base/memory/weak_ptr.h" |
29 #include "components/dns_prefetch/renderer/predictor_queue.h" | 29 #include "components/network_hints/renderer/dns_prefetch_queue.h" |
30 | 30 |
31 namespace dns_prefetch { | 31 namespace network_hints { |
32 | 32 |
33 class RendererNetPredictor { | 33 // An internal interface to the network_hints component for efficiently sending |
| 34 // DNS prefetch requests to the net stack. |
| 35 class RendererDnsPrefetch { |
34 public: | 36 public: |
35 RendererNetPredictor(); | 37 RendererDnsPrefetch(); |
36 ~RendererNetPredictor(); | 38 ~RendererDnsPrefetch(); |
37 | 39 |
38 // Push a name into the queue to be resolved. | 40 // Push a name into the queue to be resolved. |
39 void Resolve(const char* name, size_t length); | 41 void Resolve(const char* name, size_t length); |
40 | 42 |
41 // SubmitHosts processes the buffered names, and submits them for DNS | 43 // SubmitHosts processes the buffered names, and submits them for DNS |
42 // prefetching. | 44 // prefetching. |
43 // Note that browser process may decide which names should be looked up (to | 45 // Note that browser process may decide which names should be looked up (to |
44 // pre-warm the cache) based on what has been (or not been) looked up | 46 // pre-warm the cache) based on what has been (or not been) looked up |
45 // recently. | 47 // recently. |
46 // If sending for DNS lookup is incomplete (queue is not empty, or not all | 48 // If sending for DNS lookup is incomplete (queue is not empty, or not all |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Cache a tally of the count of names that haven't yet been sent | 92 // Cache a tally of the count of names that haven't yet been sent |
91 // for DNS pre-fetching. Note that we *could* recalculate this | 93 // for DNS pre-fetching. Note that we *could* recalculate this |
92 // count by iterating over domain_map_, looking for even values. | 94 // count by iterating over domain_map_, looking for even values. |
93 size_t new_name_count_; | 95 size_t new_name_count_; |
94 | 96 |
95 // We have some metrics to examine performance. We might use | 97 // We have some metrics to examine performance. We might use |
96 // these metrics to modify buffer counts etc. some day. | 98 // these metrics to modify buffer counts etc. some day. |
97 int buffer_full_discard_count_; | 99 int buffer_full_discard_count_; |
98 int numeric_ip_discard_count_; | 100 int numeric_ip_discard_count_; |
99 | 101 |
100 base::WeakPtrFactory<RendererNetPredictor> weak_factory_; | 102 base::WeakPtrFactory<RendererDnsPrefetch> weak_factory_; |
101 | 103 |
102 DISALLOW_COPY_AND_ASSIGN(RendererNetPredictor); | 104 DISALLOW_COPY_AND_ASSIGN(RendererDnsPrefetch); |
103 }; // class RendererNetPredictor | 105 }; // class RendererDnsPrefetch |
104 | 106 |
105 } // namespace dns_prefetch | 107 } // namespace network_hints |
106 | 108 |
107 #endif // COMPONENTS_DNS_PREFETCH_RENDERER_RENDERER_NET_PREDICTOR_H_ | 109 #endif // COMPONENTS_NETWORK_HINTS_RENDERER_RENDERER_DNS_PREFETCH_H_ |
OLD | NEW |