| 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_disk_cache.h" | 5 #include "content/browser/appcache/appcache_disk_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 EntryImpl(disk_cache::Entry* disk_cache_entry, | 53 EntryImpl(disk_cache::Entry* disk_cache_entry, |
| 54 AppCacheDiskCache* owner) | 54 AppCacheDiskCache* owner) |
| 55 : disk_cache_entry_(disk_cache_entry), owner_(owner) { | 55 : disk_cache_entry_(disk_cache_entry), owner_(owner) { |
| 56 DCHECK(disk_cache_entry); | 56 DCHECK(disk_cache_entry); |
| 57 DCHECK(owner); | 57 DCHECK(owner); |
| 58 owner_->AddOpenEntry(this); | 58 owner_->AddOpenEntry(this); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Entry implementation. | 61 // Entry implementation. |
| 62 virtual int Read(int index, int64 offset, net::IOBuffer* buf, int buf_len, | 62 virtual int Read(int index, int64 offset, net::IOBuffer* buf, int buf_len, |
| 63 const net::CompletionCallback& callback) OVERRIDE { | 63 const net::CompletionCallback& callback) override { |
| 64 if (offset < 0 || offset > kint32max) | 64 if (offset < 0 || offset > kint32max) |
| 65 return net::ERR_INVALID_ARGUMENT; | 65 return net::ERR_INVALID_ARGUMENT; |
| 66 if (!disk_cache_entry_) | 66 if (!disk_cache_entry_) |
| 67 return net::ERR_ABORTED; | 67 return net::ERR_ABORTED; |
| 68 return disk_cache_entry_->ReadData( | 68 return disk_cache_entry_->ReadData( |
| 69 index, static_cast<int>(offset), buf, buf_len, callback); | 69 index, static_cast<int>(offset), buf, buf_len, callback); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual int Write(int index, int64 offset, net::IOBuffer* buf, int buf_len, | 72 virtual int Write(int index, int64 offset, net::IOBuffer* buf, int buf_len, |
| 73 const net::CompletionCallback& callback) OVERRIDE { | 73 const net::CompletionCallback& callback) override { |
| 74 if (offset < 0 || offset > kint32max) | 74 if (offset < 0 || offset > kint32max) |
| 75 return net::ERR_INVALID_ARGUMENT; | 75 return net::ERR_INVALID_ARGUMENT; |
| 76 if (!disk_cache_entry_) | 76 if (!disk_cache_entry_) |
| 77 return net::ERR_ABORTED; | 77 return net::ERR_ABORTED; |
| 78 const bool kTruncate = true; | 78 const bool kTruncate = true; |
| 79 return disk_cache_entry_->WriteData( | 79 return disk_cache_entry_->WriteData( |
| 80 index, static_cast<int>(offset), buf, buf_len, callback, kTruncate); | 80 index, static_cast<int>(offset), buf, buf_len, callback, kTruncate); |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual int64 GetSize(int index) OVERRIDE { | 83 virtual int64 GetSize(int index) override { |
| 84 return disk_cache_entry_ ? disk_cache_entry_->GetDataSize(index) : 0L; | 84 return disk_cache_entry_ ? disk_cache_entry_->GetDataSize(index) : 0L; |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void Close() OVERRIDE { | 87 virtual void Close() override { |
| 88 if (disk_cache_entry_) | 88 if (disk_cache_entry_) |
| 89 disk_cache_entry_->Close(); | 89 disk_cache_entry_->Close(); |
| 90 delete this; | 90 delete this; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void Abandon() { | 93 void Abandon() { |
| 94 owner_ = NULL; | 94 owner_ = NULL; |
| 95 disk_cache_entry_->Close(); | 95 disk_cache_entry_->Close(); |
| 96 disk_cache_entry_ = NULL; | 96 disk_cache_entry_ = NULL; |
| 97 } | 97 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 NOTREACHED(); | 357 NOTREACHED(); |
| 358 break; | 358 break; |
| 359 } | 359 } |
| 360 if (rv != net::ERR_IO_PENDING) | 360 if (rv != net::ERR_IO_PENDING) |
| 361 iter->callback.Run(rv); | 361 iter->callback.Run(rv); |
| 362 } | 362 } |
| 363 pending_calls_.clear(); | 363 pending_calls_.clear(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace content | 366 } // namespace content |
| OLD | NEW |