OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Support modularity by calling to load a new SDCH filter dictionary. | 5 // Support modularity by calling to load a new SDCH filter dictionary. |
6 // Note that this sort of calling can't be done in the /net directory, as it has | 6 // Note that this sort of calling can't be done in the /net directory, as it has |
7 // no concept of the HTTP cache (which is only visible at the browser level). | 7 // no concept of the HTTP cache (which is only visible at the browser level). |
8 | 8 |
9 #ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 9 #ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
10 #define NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 10 #define NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 59 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
60 | 60 |
61 SdchManager* const manager_; | 61 SdchManager* const manager_; |
62 | 62 |
63 // A queue of URLs that are being used to download dictionaries. | 63 // A queue of URLs that are being used to download dictionaries. |
64 std::queue<GURL> fetch_queue_; | 64 std::queue<GURL> fetch_queue_; |
65 // The currently outstanding URL fetch of a dicitonary. | 65 // The currently outstanding URL fetch of a dicitonary. |
66 // If this is null, then there is no outstanding request. | 66 // If this is null, then there is no outstanding request. |
67 scoped_ptr<URLFetcher> current_fetch_; | 67 scoped_ptr<URLFetcher> current_fetch_; |
68 | 68 |
69 // Always spread out the dictionary fetches, so that they don't steal | |
70 // bandwidth from the actual page load. Create delayed tasks to spread out | |
71 // the download. | |
72 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; | |
73 bool task_is_pending_; | 69 bool task_is_pending_; |
74 | 70 |
75 // Althought the SDCH spec does not preclude a server from using a single URL | 71 // Althought the SDCH spec does not preclude a server from using a single URL |
76 // to load several distinct dictionaries (by telling a client to load a | 72 // to load several distinct dictionaries (by telling a client to load a |
77 // dictionary from an URL several times), current implementations seem to have | 73 // dictionary from an URL several times), current implementations seem to have |
78 // that 1-1 relationship (i.e., each URL points at a single dictionary, and | 74 // that 1-1 relationship (i.e., each URL points at a single dictionary, and |
79 // the dictionary content does not change over time, and hence is not worth | 75 // the dictionary content does not change over time, and hence is not worth |
80 // trying to load more than once). In addition, some dictionaries prove | 76 // trying to load more than once). In addition, some dictionaries prove |
81 // unloadable only after downloading them (because they are too large? ...or | 77 // unloadable only after downloading them (because they are too large? ...or |
82 // malformed?). As a protective element, Chromium will *only* load a | 78 // malformed?). As a protective element, Chromium will *only* load a |
83 // dictionary at most once from a given URL (so that it doesn't waste | 79 // dictionary at most once from a given URL (so that it doesn't waste |
84 // bandwidth trying repeatedly). | 80 // bandwidth trying repeatedly). |
85 // The following set lists all the dictionary URLs that we've tried to load, | 81 // The following set lists all the dictionary URLs that we've tried to load, |
86 // so that we won't try to load from an URL more than once. | 82 // so that we won't try to load from an URL more than once. |
87 // TODO(jar): Try to augment the SDCH proposal to include this restiction. | 83 // TODO(jar): Try to augment the SDCH proposal to include this restiction. |
88 std::set<GURL> attempted_load_; | 84 std::set<GURL> attempted_load_; |
89 | 85 |
90 // Store the system_url_request_context_getter to use it when we start | 86 // Store the system_url_request_context_getter to use it when we start |
91 // fetching. | 87 // fetching. |
92 scoped_refptr<URLRequestContextGetter> context_; | 88 scoped_refptr<URLRequestContextGetter> context_; |
93 | 89 |
| 90 // Always spread out the dictionary fetches, so that they don't steal |
| 91 // bandwidth from the actual page load. Create delayed tasks to spread out |
| 92 // the download. |
| 93 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; |
| 94 |
94 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); | 95 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); |
95 }; | 96 }; |
96 | 97 |
97 } // namespace net | 98 } // namespace net |
98 | 99 |
99 #endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 100 #endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
OLD | NEW |