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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 71 // Map the number of bytes read and the error code into a single |
| 72 // status value, either positive (bytes read), 0 (end of file), or |
| 73 // negative (error code). |
| 74 int GetReadResult(int bytes_read); |
| 75 |
70 // State machine implementation. | 76 // State machine implementation. |
71 int DoLoop(int rv); | 77 int DoLoop(int rv); |
72 int DoDispatchRequest(int rv); | 78 int DoSendRequest(int rv); |
73 int DoRequestStarted(int rv); | 79 int DoSendRequestComplete(int rv); |
74 int DoRead(int rv); | 80 int DoReadBody(int rv); |
| 81 int DoReadBodyComplete(int rv); |
75 int DoCompleteRequest(int rv); | 82 int DoCompleteRequest(int rv); |
76 | 83 |
77 State next_state_; | 84 State next_state_; |
78 bool in_loop_; | 85 bool in_loop_; |
79 | 86 |
80 // A queue of URLs that are being used to download dictionaries. | 87 // A queue of URLs that are being used to download dictionaries. |
81 std::queue<GURL> fetch_queue_; | 88 std::queue<GURL> fetch_queue_; |
82 | 89 |
83 // The request and buffer used for getting the current dictionary | 90 // The request and buffer used for getting the current dictionary |
84 // Both are null when a fetch is not in progress. | 91 // Both are null when a fetch is not in progress. |
(...skipping 25 matching lines...) Expand all Loading... |
110 const OnDictionaryFetchedCallback dictionary_fetched_callback_; | 117 const OnDictionaryFetchedCallback dictionary_fetched_callback_; |
111 | 118 |
112 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; | 119 base::WeakPtrFactory<SdchDictionaryFetcher> weak_factory_; |
113 | 120 |
114 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); | 121 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); |
115 }; | 122 }; |
116 | 123 |
117 } // namespace net | 124 } // namespace net |
118 | 125 |
119 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ | 126 #endif // NET_URL_REQUEST_SDCH_DICTIONARY_FETCHER_H_ |
OLD | NEW |