OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "webkit/appcache/appcache_response.h" | 5 #include "webkit/appcache/appcache_response.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 void AppCacheResponseReader::SetReadRange(int offset, int length) { | 208 void AppCacheResponseReader::SetReadRange(int offset, int length) { |
209 DCHECK(!IsReadPending() && !read_position_); | 209 DCHECK(!IsReadPending() && !read_position_); |
210 range_offset_ = offset; | 210 range_offset_ = offset; |
211 range_length_ = length; | 211 range_length_ = length; |
212 } | 212 } |
213 | 213 |
214 void AppCacheResponseReader::OnIOComplete(int result) { | 214 void AppCacheResponseReader::OnIOComplete(int result) { |
215 if (result >= 0) { | 215 if (result >= 0) { |
216 if (info_buffer_.get()) { | 216 if (info_buffer_.get()) { |
217 // Allocate and deserialize the http info structure. | 217 // Deserialize the http info structure. |
218 Pickle pickle(buffer_->data(), result); | 218 Pickle pickle(buffer_->data(), result); |
| 219 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); |
219 bool response_truncated = false; | 220 bool response_truncated = false; |
220 info_buffer_->http_info.reset(new net::HttpResponseInfo); | 221 if (!info->InitFromPickle(pickle, &response_truncated)) { |
221 info_buffer_->http_info->InitFromPickle(pickle, &response_truncated); | 222 InvokeUserCompletionCallback(net::ERR_FAILED); |
| 223 return; |
| 224 } |
222 DCHECK(!response_truncated); | 225 DCHECK(!response_truncated); |
| 226 info_buffer_->http_info.reset(info.release()); |
223 | 227 |
224 // Also return the size of the response body | 228 // Also return the size of the response body |
225 DCHECK(entry_); | 229 DCHECK(entry_); |
226 info_buffer_->response_data_size = | 230 info_buffer_->response_data_size = |
227 entry_->GetDataSize(kResponseContentIndex); | 231 entry_->GetDataSize(kResponseContentIndex); |
228 } else { | 232 } else { |
229 read_position_ += result; | 233 read_position_ += result; |
230 } | 234 } |
231 } | 235 } |
232 InvokeUserCompletionCallback(result); | 236 InvokeUserCompletionCallback(result); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 390 } |
387 | 391 |
388 if (info_buffer_) | 392 if (info_buffer_) |
389 ContinueWriteInfo(); | 393 ContinueWriteInfo(); |
390 else | 394 else |
391 ContinueWriteData(); | 395 ContinueWriteData(); |
392 } | 396 } |
393 | 397 |
394 } // namespace appcache | 398 } // namespace appcache |
395 | 399 |
OLD | NEW |