| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/appcache/appcache_response.h" | 5 #include "content/browser/appcache/appcache_response.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 AppCacheDiskCacheInterface::GetWeakPtr() { | 87 AppCacheDiskCacheInterface::GetWeakPtr() { |
| 88 return weak_factory_.GetWeakPtr(); | 88 return weak_factory_.GetWeakPtr(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 AppCacheDiskCacheInterface::~AppCacheDiskCacheInterface() {} | 91 AppCacheDiskCacheInterface::~AppCacheDiskCacheInterface() {} |
| 92 | 92 |
| 93 // AppCacheResponseIO ---------------------------------------------- | 93 // AppCacheResponseIO ---------------------------------------------- |
| 94 | 94 |
| 95 AppCacheResponseIO::AppCacheResponseIO( | 95 AppCacheResponseIO::AppCacheResponseIO( |
| 96 int64_t response_id, | 96 int64_t response_id, |
| 97 int64_t group_id, | |
| 98 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) | 97 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) |
| 99 : response_id_(response_id), | 98 : response_id_(response_id), |
| 100 group_id_(group_id), | |
| 101 disk_cache_(disk_cache), | 99 disk_cache_(disk_cache), |
| 102 entry_(NULL), | 100 entry_(NULL), |
| 103 buffer_len_(0), | 101 buffer_len_(0), |
| 104 weak_factory_(this) {} | 102 weak_factory_(this) {} |
| 105 | 103 |
| 106 AppCacheResponseIO::~AppCacheResponseIO() { | 104 AppCacheResponseIO::~AppCacheResponseIO() { |
| 107 if (entry_) | 105 if (entry_) |
| 108 entry_->Close(); | 106 entry_->Close(); |
| 109 } | 107 } |
| 110 | 108 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 open_callback_.Reset(); | 180 open_callback_.Reset(); |
| 183 } | 181 } |
| 184 OnOpenEntryComplete(); | 182 OnOpenEntryComplete(); |
| 185 } | 183 } |
| 186 | 184 |
| 187 | 185 |
| 188 // AppCacheResponseReader ---------------------------------------------- | 186 // AppCacheResponseReader ---------------------------------------------- |
| 189 | 187 |
| 190 AppCacheResponseReader::AppCacheResponseReader( | 188 AppCacheResponseReader::AppCacheResponseReader( |
| 191 int64_t response_id, | 189 int64_t response_id, |
| 192 int64_t group_id, | |
| 193 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) | 190 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) |
| 194 : AppCacheResponseIO(response_id, group_id, disk_cache), | 191 : AppCacheResponseIO(response_id, disk_cache), |
| 195 range_offset_(0), | 192 range_offset_(0), |
| 196 range_length_(std::numeric_limits<int32_t>::max()), | 193 range_length_(std::numeric_limits<int32_t>::max()), |
| 197 read_position_(0), | 194 read_position_(0), |
| 198 reading_metadata_size_(0), | 195 reading_metadata_size_(0), |
| 199 weak_factory_(this) {} | 196 weak_factory_(this) {} |
| 200 | 197 |
| 201 AppCacheResponseReader::~AppCacheResponseReader() { | 198 AppCacheResponseReader::~AppCacheResponseReader() { |
| 202 } | 199 } |
| 203 | 200 |
| 204 void AppCacheResponseReader::ReadInfo(HttpResponseInfoIOBuffer* info_buf, | 201 void AppCacheResponseReader::ReadInfo(HttpResponseInfoIOBuffer* info_buf, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 if (info_buffer_.get()) | 304 if (info_buffer_.get()) |
| 308 ContinueReadInfo(); | 305 ContinueReadInfo(); |
| 309 else | 306 else |
| 310 ContinueReadData(); | 307 ContinueReadData(); |
| 311 } | 308 } |
| 312 | 309 |
| 313 // AppCacheResponseWriter ---------------------------------------------- | 310 // AppCacheResponseWriter ---------------------------------------------- |
| 314 | 311 |
| 315 AppCacheResponseWriter::AppCacheResponseWriter( | 312 AppCacheResponseWriter::AppCacheResponseWriter( |
| 316 int64_t response_id, | 313 int64_t response_id, |
| 317 int64_t group_id, | |
| 318 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) | 314 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) |
| 319 : AppCacheResponseIO(response_id, group_id, disk_cache), | 315 : AppCacheResponseIO(response_id, disk_cache), |
| 320 info_size_(0), | 316 info_size_(0), |
| 321 write_position_(0), | 317 write_position_(0), |
| 322 write_amount_(0), | 318 write_amount_(0), |
| 323 creation_phase_(INITIAL_ATTEMPT), | 319 creation_phase_(INITIAL_ATTEMPT), |
| 324 weak_factory_(this) {} | 320 weak_factory_(this) {} |
| 325 | 321 |
| 326 AppCacheResponseWriter::~AppCacheResponseWriter() { | 322 AppCacheResponseWriter::~AppCacheResponseWriter() { |
| 327 } | 323 } |
| 328 | 324 |
| 329 void AppCacheResponseWriter::WriteInfo( | 325 void AppCacheResponseWriter::WriteInfo( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 if (info_buffer_.get()) | 448 if (info_buffer_.get()) |
| 453 ContinueWriteInfo(); | 449 ContinueWriteInfo(); |
| 454 else | 450 else |
| 455 ContinueWriteData(); | 451 ContinueWriteData(); |
| 456 } | 452 } |
| 457 | 453 |
| 458 // AppCacheResponseMetadataWriter ---------------------------------------------- | 454 // AppCacheResponseMetadataWriter ---------------------------------------------- |
| 459 | 455 |
| 460 AppCacheResponseMetadataWriter::AppCacheResponseMetadataWriter( | 456 AppCacheResponseMetadataWriter::AppCacheResponseMetadataWriter( |
| 461 int64_t response_id, | 457 int64_t response_id, |
| 462 int64_t group_id, | |
| 463 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) | 458 const base::WeakPtr<AppCacheDiskCacheInterface>& disk_cache) |
| 464 : AppCacheResponseIO(response_id, group_id, disk_cache), | 459 : AppCacheResponseIO(response_id, disk_cache), |
| 465 write_amount_(0), | 460 write_amount_(0), |
| 466 weak_factory_(this) {} | 461 weak_factory_(this) {} |
| 467 | 462 |
| 468 AppCacheResponseMetadataWriter::~AppCacheResponseMetadataWriter() { | 463 AppCacheResponseMetadataWriter::~AppCacheResponseMetadataWriter() { |
| 469 } | 464 } |
| 470 | 465 |
| 471 void AppCacheResponseMetadataWriter::WriteMetadata( | 466 void AppCacheResponseMetadataWriter::WriteMetadata( |
| 472 net::IOBuffer* buf, | 467 net::IOBuffer* buf, |
| 473 int buf_len, | 468 int buf_len, |
| 474 const net::CompletionCallback& callback) { | 469 const net::CompletionCallback& callback) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 491 } | 486 } |
| 492 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); | 487 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); |
| 493 } | 488 } |
| 494 | 489 |
| 495 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { | 490 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { |
| 496 DCHECK(result < 0 || write_amount_ == result); | 491 DCHECK(result < 0 || write_amount_ == result); |
| 497 InvokeUserCompletionCallback(result); | 492 InvokeUserCompletionCallback(result); |
| 498 } | 493 } |
| 499 | 494 |
| 500 } // namespace content | 495 } // namespace content |
| OLD | NEW |