Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: net/http/mock_http_cache.cc

Issue 2591743002: Implement a method to get the total size of a cache entry (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/http/mock_http_cache.h" 5 #include "net/http/mock_http_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 base::Time MockDiskEntry::GetLastModified() const { 97 base::Time MockDiskEntry::GetLastModified() const {
98 return base::Time::Now(); 98 return base::Time::Now();
99 } 99 }
100 100
101 int32_t MockDiskEntry::GetDataSize(int index) const { 101 int32_t MockDiskEntry::GetDataSize(int index) const {
102 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices); 102 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
103 return static_cast<int32_t>(data_[index].size()); 103 return static_cast<int32_t>(data_[index].size());
104 } 104 }
105 105
106 int64_t MockDiskEntry::GetEntrySize() const {
107 int64_t size = key_.size();
108 for (int i = 0; i < kNumCacheEntryDataIndices; ++i) {
109 size += GetDataSize(i);
110 }
111 return size;
112 }
113
106 int MockDiskEntry::ReadData(int index, 114 int MockDiskEntry::ReadData(int index,
107 int offset, 115 int offset,
108 IOBuffer* buf, 116 IOBuffer* buf,
109 int buf_len, 117 int buf_len,
110 const CompletionCallback& callback) { 118 const CompletionCallback& callback) {
111 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices); 119 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
112 DCHECK(!callback.is_null()); 120 DCHECK(!callback.is_null());
113 121
114 if (fail_requests_) 122 if (fail_requests_)
115 return ERR_CACHE_READ_FAILURE; 123 return ERR_CACHE_READ_FAILURE;
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (!callback_.is_null()) { 691 if (!callback_.is_null()) {
684 if (!fail_) 692 if (!fail_)
685 backend_->reset(new MockDiskCache()); 693 backend_->reset(new MockDiskCache());
686 CompletionCallback cb = callback_; 694 CompletionCallback cb = callback_;
687 callback_.Reset(); 695 callback_.Reset();
688 cb.Run(Result()); // This object can be deleted here. 696 cb.Run(Result()); // This object can be deleted here.
689 } 697 }
690 } 698 }
691 699
692 } // namespace net 700 } // namespace net
OLDNEW
« no previous file with comments | « net/http/mock_http_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698