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 // TODO(rdsmith): This class needs to delegate URLRequest::Delegate methods | 5 // TODO(rdsmith): This class needs to delegate URLRequest::Delegate methods |
6 // to the net/ embedder for correct implementation of authentication. | 6 // to the net/ embedder for correct implementation of authentication. |
7 // Specifically, this class needs the embedder to provide functionality | 7 // Specifically, this class needs the embedder to provide functionality |
8 // corresponding to | 8 // corresponding to |
9 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested}. | 9 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested}. |
10 | 10 |
11 #ifndef NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ | 11 #ifndef NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ |
12 #define NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ | 12 #define NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
21 #include "net/base/sdch_manager.h" | 21 #include "net/base/sdch_manager.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 22 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 class NetLogWithSource; | 28 class NetLogWithSource; |
29 class URLRequest; | 29 class URLRequest; |
30 | 30 |
31 // This class is used by embedder SDCH policy object to fetch | 31 // This class is used by embedder SDCH policy object to fetch |
32 // dictionaries. It queues requests for dictionaries and dispatches | 32 // dictionaries. It queues requests for dictionaries and dispatches |
33 // them serially, implementing the URLRequest::Delegate interface to | 33 // them serially, implementing the URLRequest::Delegate interface to |
34 // handle callbacks (but see above TODO). It tracks all requests, only | 34 // handle callbacks (but see above TODO). It tracks all requests, only |
35 // attempting to fetch each dictionary once. | 35 // attempting to fetch each dictionary once. |
36 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate, | 36 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate { |
37 public base::NonThreadSafe { | |
38 public: | 37 public: |
39 typedef base::Callback<void(const std::string& dictionary_text, | 38 typedef base::Callback<void(const std::string& dictionary_text, |
40 const GURL& dictionary_url, | 39 const GURL& dictionary_url, |
41 const NetLogWithSource& net_log, | 40 const NetLogWithSource& net_log, |
42 bool was_from_cache)> | 41 bool was_from_cache)> |
43 OnDictionaryFetchedCallback; | 42 OnDictionaryFetchedCallback; |
44 | 43 |
45 // The consumer must guarantee that |*context| outlives this object. | 44 // The consumer must guarantee that |*context| outlives this object. |
46 explicit SdchDictionaryFetcher(URLRequestContext* context); | 45 explicit SdchDictionaryFetcher(URLRequestContext* context); |
47 ~SdchDictionaryFetcher() override; | 46 ~SdchDictionaryFetcher() override; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 113 |
115 // The currently accumulating dictionary. Stored as a unique_ptr so all memory | 114 // The currently accumulating dictionary. Stored as a unique_ptr so all memory |
116 // it consumes can be easily freed, as it gets quite big, and | 115 // it consumes can be easily freed, as it gets quite big, and |
117 // std::string::clear() may not free memory. | 116 // std::string::clear() may not free memory. |
118 std::unique_ptr<std::string> dictionary_; | 117 std::unique_ptr<std::string> dictionary_; |
119 | 118 |
120 // Store the URLRequestContext associated with the owning SdchManager for | 119 // Store the URLRequestContext associated with the owning SdchManager for |
121 // use while fetching. | 120 // use while fetching. |
122 URLRequestContext* const context_; | 121 URLRequestContext* const context_; |
123 | 122 |
| 123 THREAD_CHECKER(thread_checker_); |
| 124 |
124 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); | 125 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); |
125 }; | 126 }; |
126 | 127 |
127 } // namespace net | 128 } // namespace net |
128 | 129 |
129 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ | 130 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ |
OLD | NEW |