| 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 #include "net/base/sdch_dictionary_fetcher.h" | 5 #include "net/base/sdch_dictionary_fetcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 return OK; | 197 return OK; |
| 198 } | 198 } |
| 199 | 199 |
| 200 next_state_ = STATE_REQUEST_READING; | 200 next_state_ = STATE_REQUEST_READING; |
| 201 int bytes_read = 0; | 201 int bytes_read = 0; |
| 202 if (!current_request_->Read(buffer_.get(), kBufferSize, &bytes_read)) { | 202 if (!current_request_->Read(buffer_.get(), kBufferSize, &bytes_read)) { |
| 203 if (current_request_->status().is_io_pending()) | 203 if (current_request_->status().is_io_pending()) |
| 204 return ERR_IO_PENDING; | 204 return ERR_IO_PENDING; |
| 205 | 205 |
| 206 DCHECK_NE(current_request_->status().error(), OK); | |
| 207 if (current_request_->status().error() == OK) { | 206 if (current_request_->status().error() == OK) { |
| 208 // This "should never happen", but if it does the result will be | 207 // This "should never happen", but if it does the result will be |
| 209 // an infinite loop. It's not clear how to handle a read failure | 208 // an infinite loop. It's not clear how to handle a read failure |
| 210 // without a promise to invoke the callback at some point in the future, | 209 // without a promise to invoke the callback at some point in the future, |
| 211 // so the request is failed. | 210 // so the request is failed. |
| 212 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_FETCH_READ_FAILED); | 211 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_FETCH_READ_FAILED); |
| 212 DLOG(FATAL) << |
| 213 "URLRequest::Read() returned false without IO pending or error!"; |
| 213 return ERR_FAILED; | 214 return ERR_FAILED; |
| 214 } | 215 } |
| 215 | 216 |
| 216 return current_request_->status().error(); | 217 return current_request_->status().error(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 if (bytes_read != 0) | 220 if (bytes_read != 0) |
| 220 dictionary_.append(buffer_->data(), bytes_read); | 221 dictionary_.append(buffer_->data(), bytes_read); |
| 221 else | 222 else |
| 222 next_state_ = STATE_REQUEST_COMPLETE; | 223 next_state_ = STATE_REQUEST_COMPLETE; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 234 current_request_.reset(); | 235 current_request_.reset(); |
| 235 buffer_ = NULL; | 236 buffer_ = NULL; |
| 236 dictionary_.clear(); | 237 dictionary_.clear(); |
| 237 | 238 |
| 238 next_state_ = STATE_IDLE; | 239 next_state_ = STATE_IDLE; |
| 239 | 240 |
| 240 return OK; | 241 return OK; |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace net | 244 } // namespace net |
| OLD | NEW |