Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: net/url_request/sdch_dictionary_fetcher.h

Issue 877443002: Naming and refactoring changes to SdchDictionaryFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd to p313320 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 19 matching lines...) Expand all
30 // This class is used by embedder SDCH policy object to fetch 30 // This class is used by embedder SDCH policy object to fetch
31 // dictionaries. It queues requests for dictionaries and dispatches 31 // dictionaries. It queues requests for dictionaries and dispatches
32 // them serially, implementing the URLRequest::Delegate interface to 32 // them serially, implementing the URLRequest::Delegate interface to
33 // handle callbacks (but see above TODO). It tracks all requests, only 33 // handle callbacks (but see above TODO). It tracks all requests, only
34 // attempting to fetch each dictionary once. 34 // attempting to fetch each dictionary once.
35 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate, 35 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
36 public base::NonThreadSafe { 36 public base::NonThreadSafe {
37 public: 37 public:
38 typedef base::Callback<void(const std::string& dictionary_text, 38 typedef base::Callback<void(const std::string& dictionary_text,
39 const GURL& dictionary_url, 39 const GURL& dictionary_url,
40 const BoundNetLog& net_log)> 40 const BoundNetLog& net_log)>
mmenke 2015/01/30 16:20:44 While you're here, should include net/base/net_log
Randy Smith (Not in Mondays) 2015/01/30 19:21:58 ref_counted.h & macros.h: Done. I couldn't figure
mmenke 2015/01/30 19:27:52 You're right. Almost everything in net/ keeps a B
41 OnDictionaryFetchedCallback; 41 OnDictionaryFetchedCallback;
42 42
43 // The consumer must guarantee that |*context| outlives this object. 43 // The consumer must guarantee that |*context| outlives this object.
44 // |callback| will be called on successful dictionary fetch 44 // |callback| will be called on successful dictionary fetch
45 // requested through Schedule(). |callback| will not be called 45 // requested through Schedule(). |callback| will not be called
46 // after object destruction. 46 // after object destruction.
47 SdchDictionaryFetcher(URLRequestContext* context, 47 SdchDictionaryFetcher(URLRequestContext* context,
48 const OnDictionaryFetchedCallback& callback); 48 const OnDictionaryFetchedCallback& callback);
49 ~SdchDictionaryFetcher() override; 49 ~SdchDictionaryFetcher() override;
50 50
51 // Request a new dictionary fetch. 51 // Request a new dictionary fetch.
52 void Schedule(const GURL& dictionary_url); 52 void Schedule(const GURL& dictionary_url);
53 53
54 // Cancel any in-progress requests. 54 // Cancel any in-progress requests.
55 void Cancel(); 55 void Cancel();
56 56
57 // Implementation of URLRequest::Delegate methods. 57 // Implementation of URLRequest::Delegate methods.
58 void OnResponseStarted(URLRequest* request) override; 58 void OnResponseStarted(URLRequest* request) override;
59 void OnReadCompleted(URLRequest* request, int bytes_read) override; 59 void OnReadCompleted(URLRequest* request, int bytes_read) override;
60 60
61 private: 61 private:
62 enum State { 62 enum State {
63 STATE_NONE, 63 STATE_NONE,
64 STATE_IDLE, 64 STATE_SEND_REQUEST,
65 STATE_REQUEST_STARTED, 65 STATE_SEND_REQUEST_COMPLETE,
66 STATE_REQUEST_READING, 66 STATE_READ_BODY,
67 STATE_READ_BODY_COMPLETE,
67 STATE_REQUEST_COMPLETE, 68 STATE_REQUEST_COMPLETE,
68 }; 69 };
69 70
70 // State machine implementation. 71 // State machine implementation.
71 int DoLoop(int rv); 72 int DoLoop(int rv);
72 int DoDispatchRequest(int rv); 73 int DoSendRequest(int rv);
73 int DoRequestStarted(int rv); 74 int DoSendRequestComplete(int rv);
74 int DoRead(int rv); 75 int DoReadBody(int rv);
76 int DoReadBodyComplete(int rv);
75 int DoCompleteRequest(int rv); 77 int DoCompleteRequest(int rv);
76 78
77 State next_state_; 79 State next_state_;
78 bool in_loop_; 80 bool in_loop_;
79 81
80 // A queue of URLs that are being used to download dictionaries. 82 // A queue of URLs that are being used to download dictionaries.
81 std::queue<GURL> fetch_queue_; 83 std::queue<GURL> fetch_queue_;
82 84
83 // The request and buffer used for getting the current dictionary 85 // The request and buffer used for getting the current dictionary
84 // Both are null when a fetch is not in progress. 86 // Both are null when a fetch is not in progress.
(...skipping 25 matching lines...) Expand all
110 const OnDictionaryFetchedCallback dictionary_fetched_callback_; 112 const OnDictionaryFetchedCallback dictionary_fetched_callback_;
111 113
112 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; 114 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_;
113 115
114 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); 116 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
115 }; 117 };
116 118
117 } // namespace net 119 } // namespace net
118 120
119 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ 121 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | net/url_request/sdch_dictionary_fetcher.cc » ('j') | net/url_request/sdch_dictionary_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698