Chromium Code Reviews| 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 // 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 CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ | 9 #ifndef CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ |
| 10 #define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ | 10 #define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // completes (either successfully or with failure). | 52 // completes (either successfully or with failure). |
| 53 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 53 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| 54 | 54 |
| 55 // A queue of URLs that are being used to download dictionaries. | 55 // A queue of URLs that are being used to download dictionaries. |
| 56 std::queue<GURL> fetch_queue_; | 56 std::queue<GURL> fetch_queue_; |
| 57 // The currently outstanding URL fetch of a dicitonary. | 57 // The currently outstanding URL fetch of a dicitonary. |
| 58 // If this is null, then there is no outstanding request. | 58 // If this is null, then there is no outstanding request. |
| 59 scoped_ptr<content::URLFetcher> current_fetch_; | 59 scoped_ptr<content::URLFetcher> current_fetch_; |
| 60 | 60 |
| 61 // Always spread out the dictionary fetches, so that they don't steal | 61 // Always spread out the dictionary fetches, so that they don't steal |
| 62 // bandwidth from the actual page load. Create delayed tasks to spread out | 62 // bandwidth from the actual page load. Create delayed tasks to spread out |
|
wtc
2011/11/17 08:16:21
Is this comment still accurate? Does weak_factory
| |
| 63 // the download. | 63 // the download. |
| 64 ScopedRunnableMethodFactory<SdchDictionaryFetcher> method_factory_; | 64 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; |
| 65 bool task_is_pending_; | 65 bool task_is_pending_; |
| 66 | 66 |
| 67 // Althought the SDCH spec does not preclude a server from using a single URL | 67 // Althought the SDCH spec does not preclude a server from using a single URL |
| 68 // to load several distinct dictionaries (by telling a client to load a | 68 // to load several distinct dictionaries (by telling a client to load a |
| 69 // dictionary from an URL several times), current implementations seem to have | 69 // dictionary from an URL several times), current implementations seem to have |
| 70 // that 1-1 relationship (i.e., each URL points at a single dictionary, and | 70 // that 1-1 relationship (i.e., each URL points at a single dictionary, and |
| 71 // the dictionary content does not change over time, and hence is not worth | 71 // the dictionary content does not change over time, and hence is not worth |
| 72 // trying to load more than once). In addition, some dictionaries prove | 72 // trying to load more than once). In addition, some dictionaries prove |
| 73 // unloadable only after downloading them (because they are too large? ...or | 73 // unloadable only after downloading them (because they are too large? ...or |
| 74 // malformed?). As a protective element, Chromium will *only* load a | 74 // malformed?). As a protective element, Chromium will *only* load a |
| 75 // dictionary at most once from a given URL (so that it doesn't waste | 75 // dictionary at most once from a given URL (so that it doesn't waste |
| 76 // bandwidth trying repeatedly). | 76 // bandwidth trying repeatedly). |
| 77 // The following set lists all the dictionary URLs that we've tried to load, | 77 // The following set lists all the dictionary URLs that we've tried to load, |
| 78 // so that we won't try to load from an URL more than once. | 78 // so that we won't try to load from an URL more than once. |
| 79 // TODO(jar): Try to augment the SDCH proposal to include this restiction. | 79 // TODO(jar): Try to augment the SDCH proposal to include this restiction. |
| 80 std::set<GURL> attempted_load_; | 80 std::set<GURL> attempted_load_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); | 82 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 #endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ | 85 #endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ |
| OLD | NEW |