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

Side by Side Diff: net/disk_cache/mem_entry_impl.cc

Issue 21236: Revert cl 9528 to fix mac test_shell_tests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/mem_entry_impl.h ('k') | net/disk_cache/stress_cache.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/disk_cache/mem_entry_impl.h" 5 #include "net/disk_cache/mem_entry_impl.h"
6 6
7 #include "net/base/io_buffer.h"
8 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
9 #include "net/disk_cache/mem_backend_impl.h" 8 #include "net/disk_cache/mem_backend_impl.h"
10 9
11 using base::Time; 10 using base::Time;
12 11
13 namespace disk_cache { 12 namespace disk_cache {
14 13
15 MemEntryImpl::MemEntryImpl(MemBackendImpl* backend) { 14 MemEntryImpl::MemEntryImpl(MemBackendImpl* backend) {
16 doomed_ = false; 15 doomed_ = false;
17 backend_ = backend; 16 backend_ = backend;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return last_modified_; 75 return last_modified_;
77 } 76 }
78 77
79 int32 MemEntryImpl::GetDataSize(int index) const { 78 int32 MemEntryImpl::GetDataSize(int index) const {
80 if (index < 0 || index >= NUM_STREAMS) 79 if (index < 0 || index >= NUM_STREAMS)
81 return 0; 80 return 0;
82 81
83 return data_size_[index]; 82 return data_size_[index];
84 } 83 }
85 84
86 int MemEntryImpl::ReadData(int index, int offset, net::IOBuffer* buf, 85 int MemEntryImpl::ReadData(int index, int offset, char* buf, int buf_len,
87 int buf_len, net::CompletionCallback* completion_callback) { 86 net::CompletionCallback* completion_callback) {
88 if (index < 0 || index >= NUM_STREAMS) 87 if (index < 0 || index >= NUM_STREAMS)
89 return net::ERR_INVALID_ARGUMENT; 88 return net::ERR_INVALID_ARGUMENT;
90 89
91 int entry_size = GetDataSize(index); 90 int entry_size = GetDataSize(index);
92 if (offset >= entry_size || offset < 0 || !buf_len) 91 if (offset >= entry_size || offset < 0 || !buf_len)
93 return 0; 92 return 0;
94 93
95 if (buf_len < 0) 94 if (buf_len < 0)
96 return net::ERR_INVALID_ARGUMENT; 95 return net::ERR_INVALID_ARGUMENT;
97 96
98 if (offset + buf_len > entry_size) 97 if (offset + buf_len > entry_size)
99 buf_len = entry_size - offset; 98 buf_len = entry_size - offset;
100 99
101 UpdateRank(false); 100 UpdateRank(false);
102 101
103 memcpy(buf->data() , &(data_[index])[offset], buf_len); 102 memcpy(buf , &(data_[index])[offset], buf_len);
104 return buf_len; 103 return buf_len;
105 } 104 }
106 105
107 int MemEntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, 106 int MemEntryImpl::WriteData(int index, int offset, const char* buf, int buf_len,
108 int buf_len, net::CompletionCallback* completion_callback, bool truncate) { 107 net::CompletionCallback* completion_callback,
108 bool truncate) {
109 if (index < 0 || index >= NUM_STREAMS) 109 if (index < 0 || index >= NUM_STREAMS)
110 return net::ERR_INVALID_ARGUMENT; 110 return net::ERR_INVALID_ARGUMENT;
111 111
112 if (offset < 0 || buf_len < 0) 112 if (offset < 0 || buf_len < 0)
113 return net::ERR_INVALID_ARGUMENT; 113 return net::ERR_INVALID_ARGUMENT;
114 114
115 int max_file_size = backend_->MaxFileSize(); 115 int max_file_size = backend_->MaxFileSize();
116 116
117 // offset of buf_len could be negative numbers. 117 // offset of buf_len could be negative numbers.
118 if (offset > max_file_size || buf_len > max_file_size || 118 if (offset > max_file_size || buf_len > max_file_size ||
(...skipping 17 matching lines...) Expand all
136 backend_->ModifyStorageSize(entry_size, offset + buf_len); 136 backend_->ModifyStorageSize(entry_size, offset + buf_len);
137 data_size_[index] = offset + buf_len; 137 data_size_[index] = offset + buf_len;
138 } 138 }
139 } 139 }
140 140
141 UpdateRank(true); 141 UpdateRank(true);
142 142
143 if (!buf_len) 143 if (!buf_len)
144 return 0; 144 return 0;
145 145
146 memcpy(&(data_[index])[offset], buf->data(), buf_len); 146 memcpy(&(data_[index])[offset], buf, buf_len);
147 return buf_len; 147 return buf_len;
148 } 148 }
149 149
150 void MemEntryImpl::PrepareTarget(int index, int offset, int buf_len) { 150 void MemEntryImpl::PrepareTarget(int index, int offset, int buf_len) {
151 int entry_size = GetDataSize(index); 151 int entry_size = GetDataSize(index);
152 152
153 if (entry_size >= offset + buf_len) 153 if (entry_size >= offset + buf_len)
154 return; // Not growing the stored data. 154 return; // Not growing the stored data.
155 155
156 if (static_cast<int>(data_[index].size()) < offset + buf_len) 156 if (static_cast<int>(data_[index].size()) < offset + buf_len)
(...skipping 13 matching lines...) Expand all
170 170
171 if (modified) 171 if (modified)
172 last_modified_ = current; 172 last_modified_ = current;
173 173
174 if (!doomed_) 174 if (!doomed_)
175 backend_->UpdateRank(this); 175 backend_->UpdateRank(this);
176 } 176 }
177 177
178 } // namespace disk_cache 178 } // namespace disk_cache
179 179
OLDNEW
« no previous file with comments | « net/disk_cache/mem_entry_impl.h ('k') | net/disk_cache/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698