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 be moved out to the net/ embedder and | 5 // TODO(rdsmith): This class needs to be moved out to the net/ embedder and |
6 // hooked into whatever mechanisms the embedder uses for authentication. | 6 // hooked into whatever mechanisms the embedder uses for authentication. |
7 // Specifically, this class needs methods overriding | 7 // Specifically, this class needs methods overriding |
8 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested} and can't | 8 // URLRequest::Delegate::{OnAuthRequired,OnCertificateRequested} and can't |
9 // implement them at the net/ layer. | 9 // implement them at the net/ layer. |
10 | 10 |
11 #ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 11 #ifndef NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
12 #define NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 12 #define NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
13 | 13 |
14 #include <queue> | 14 #include <queue> |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "net/base/net_log.h" | |
Randy Smith (Not in Mondays)
2014/09/29 21:21:57
Why is this needed in the header file? It doesn't
baranovich
2014/09/30 13:16:51
Done.
| |
21 #include "net/base/sdch_manager.h" | 22 #include "net/base/sdch_manager.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
24 | 25 |
25 namespace net { | 26 namespace net { |
26 | 27 |
27 class URLRequest; | 28 class URLRequest; |
28 class URLRequestThrottlerEntryInterface; | 29 class URLRequestThrottlerEntryInterface; |
29 | 30 |
30 // This class implements the SdchFetcher interface. It queues requests | 31 // This class implements the SdchFetcher interface. It queues requests |
31 // for dictionaries and dispatches them serially, implementing | 32 // for dictionaries and dispatches them serially, implementing |
32 // the URLRequest::Delegate interface to handle callbacks (but see above | 33 // the URLRequest::Delegate interface to handle callbacks (but see above |
33 // TODO). It tracks all requests, only attempting to fetch each dictionary | 34 // TODO). It tracks all requests, only attempting to fetch each dictionary |
34 // once. | 35 // once. |
35 class NET_EXPORT SdchDictionaryFetcher | 36 class NET_EXPORT SdchDictionaryFetcher |
36 : public SdchFetcher, | 37 : public SdchFetcher, |
37 public URLRequest::Delegate, | 38 public URLRequest::Delegate, |
38 public base::NonThreadSafe { | 39 public base::NonThreadSafe { |
39 public: | 40 public: |
40 // The consumer must guarantee that |*consumer| and |*context| outlive | 41 // The consumer must guarantee that |*consumer| and |*context| outlive |
41 // this object. | 42 // this object. |
42 SdchDictionaryFetcher(SdchFetcher::Delegate* consumer, | 43 SdchDictionaryFetcher(SdchFetcher::Delegate* consumer, |
43 URLRequestContext* context); | 44 URLRequestContext* context); |
44 virtual ~SdchDictionaryFetcher(); | 45 virtual ~SdchDictionaryFetcher(); |
45 | 46 |
46 // Implementation of SdchFetcher methods. | 47 // Implementation of SdchFetcher methods. |
47 virtual void Schedule(const GURL& dictionary_url) OVERRIDE; | 48 virtual ScheduleResult Schedule(const GURL& dictionary_url) OVERRIDE; |
48 virtual void Cancel() OVERRIDE; | 49 virtual void Cancel() OVERRIDE; |
49 | 50 |
50 // Implementation of URLRequest::Delegate methods. | 51 // Implementation of URLRequest::Delegate methods. |
51 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; | 52 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; |
52 virtual void OnReadCompleted(URLRequest* request, int bytes_read) OVERRIDE; | 53 virtual void OnReadCompleted(URLRequest* request, int bytes_read) OVERRIDE; |
53 | 54 |
54 private: | 55 private: |
55 enum State { | 56 enum State { |
56 STATE_NONE, | 57 STATE_NONE, |
57 STATE_IDLE, | 58 STATE_IDLE, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 URLRequestContext* context_; | 104 URLRequestContext* context_; |
104 | 105 |
105 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; | 106 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; |
106 | 107 |
107 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); | 108 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); |
108 }; | 109 }; |
109 | 110 |
110 } // namespace net | 111 } // namespace net |
111 | 112 |
112 #endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_ | 113 #endif // NET_BASE_SDCH_DICTIONARY_FETCHER_H_ |
OLD | NEW |