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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/url_request/sdch_dictionary_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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 <queue> 14 #include <queue>
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 17
18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
20 #include "base/threading/non_thread_safe.h" 22 #include "base/threading/non_thread_safe.h"
21 #include "net/base/sdch_manager.h" 23 #include "net/base/sdch_manager.h"
22 #include "net/url_request/url_fetcher_delegate.h" 24 #include "net/url_request/url_fetcher_delegate.h"
23 #include "net/url_request/url_request.h" 25 #include "net/url_request/url_request.h"
26 #include "url/gurl.h"
24 27
25 namespace net { 28 namespace net {
26 29
30 class BoundNetLog;
27 class URLRequest; 31 class URLRequest;
28 class URLRequestThrottlerEntryInterface; 32 class URLRequestThrottlerEntryInterface;
29 33
30 // This class is used by embedder SDCH policy object to fetch 34 // This class is used by embedder SDCH policy object to fetch
31 // dictionaries. It queues requests for dictionaries and dispatches 35 // dictionaries. It queues requests for dictionaries and dispatches
32 // them serially, implementing the URLRequest::Delegate interface to 36 // them serially, implementing the URLRequest::Delegate interface to
33 // handle callbacks (but see above TODO). It tracks all requests, only 37 // handle callbacks (but see above TODO). It tracks all requests, only
34 // attempting to fetch each dictionary once. 38 // attempting to fetch each dictionary once.
35 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate, 39 class NET_EXPORT SdchDictionaryFetcher : public URLRequest::Delegate,
36 public base::NonThreadSafe { 40 public base::NonThreadSafe {
(...skipping 17 matching lines...) Expand all
54 // Cancel any in-progress requests. 58 // Cancel any in-progress requests.
55 void Cancel(); 59 void Cancel();
56 60
57 // Implementation of URLRequest::Delegate methods. 61 // Implementation of URLRequest::Delegate methods.
58 void OnResponseStarted(URLRequest* request) override; 62 void OnResponseStarted(URLRequest* request) override;
59 void OnReadCompleted(URLRequest* request, int bytes_read) override; 63 void OnReadCompleted(URLRequest* request, int bytes_read) override;
60 64
61 private: 65 private:
62 enum State { 66 enum State {
63 STATE_NONE, 67 STATE_NONE,
64 STATE_IDLE, 68 STATE_SEND_REQUEST,
65 STATE_REQUEST_STARTED, 69 STATE_SEND_REQUEST_COMPLETE,
66 STATE_REQUEST_READING, 70 STATE_READ_BODY,
71 STATE_READ_BODY_COMPLETE,
67 STATE_REQUEST_COMPLETE, 72 STATE_REQUEST_COMPLETE,
68 }; 73 };
69 74
70 // State machine implementation. 75 // State machine implementation.
71 int DoLoop(int rv); 76 int DoLoop(int rv);
72 int DoDispatchRequest(int rv); 77 int DoSendRequest(int rv);
73 int DoRequestStarted(int rv); 78 int DoSendRequestComplete(int rv);
74 int DoRead(int rv); 79 int DoReadBody(int rv);
80 int DoReadBodyComplete(int rv);
75 int DoCompleteRequest(int rv); 81 int DoCompleteRequest(int rv);
76 82
77 State next_state_; 83 State next_state_;
78 bool in_loop_; 84 bool in_loop_;
79 85
80 // A queue of URLs that are being used to download dictionaries. 86 // A queue of URLs that are being used to download dictionaries.
81 std::queue<GURL> fetch_queue_; 87 std::queue<GURL> fetch_queue_;
82 88
83 // The request and buffer used for getting the current dictionary 89 // The request and buffer used for getting the current dictionary
84 // Both are null when a fetch is not in progress. 90 // Both are null when a fetch is not in progress.
(...skipping 25 matching lines...) Expand all
110 const OnDictionaryFetchedCallback dictionary_fetched_callback_; 116 const OnDictionaryFetchedCallback dictionary_fetched_callback_;
111 117
112 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; 118 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_;
113 119
114 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); 120 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
115 }; 121 };
116 122
117 } // namespace net 123 } // namespace net
118 124
119 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ 125 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_
OLDNEW
« no previous file with comments | « net/udp/udp_socket_win.cc ('k') | net/url_request/sdch_dictionary_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698