| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 int result = InternalReadData(index, offset, buf, buf_len); | 178 int result = InternalReadData(index, offset, buf, buf_len); |
| 179 | 179 |
| 180 if (net_log_.IsLoggingAllEvents()) { | 180 if (net_log_.IsLoggingAllEvents()) { |
| 181 net_log_.EndEvent( | 181 net_log_.EndEvent( |
| 182 net::NetLog::TYPE_ENTRY_READ_DATA, | 182 net::NetLog::TYPE_ENTRY_READ_DATA, |
| 183 make_scoped_refptr(new ReadWriteCompleteParameters(result))); | 183 make_scoped_refptr(new ReadWriteCompleteParameters(result))); |
| 184 } | 184 } |
| 185 return result; | 185 return result; |
| 186 } | 186 } |
| 187 | 187 |
| 188 int MemEntryImpl::ReadData( | |
| 189 int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 190 const net::CompletionCallback& completion_callback) { | |
| 191 if (net_log_.IsLoggingAllEvents()) { | |
| 192 net_log_.BeginEvent( | |
| 193 net::NetLog::TYPE_ENTRY_READ_DATA, | |
| 194 make_scoped_refptr( | |
| 195 new ReadWriteDataParameters(index, offset, buf_len, false))); | |
| 196 } | |
| 197 | |
| 198 int result = InternalReadData(index, offset, buf, buf_len); | |
| 199 | |
| 200 if (net_log_.IsLoggingAllEvents()) { | |
| 201 net_log_.EndEvent( | |
| 202 net::NetLog::TYPE_ENTRY_READ_DATA, | |
| 203 make_scoped_refptr(new ReadWriteCompleteParameters(result))); | |
| 204 } | |
| 205 return result; | |
| 206 } | |
| 207 | |
| 208 int MemEntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, | 188 int MemEntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, |
| 209 int buf_len, net::OldCompletionCallback* completion_callback, bool truncate)
{ | 189 int buf_len, net::OldCompletionCallback* completion_callback, bool truncate)
{ |
| 210 if (net_log_.IsLoggingAllEvents()) { | 190 if (net_log_.IsLoggingAllEvents()) { |
| 211 net_log_.BeginEvent( | 191 net_log_.BeginEvent( |
| 212 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 192 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 213 make_scoped_refptr( | 193 make_scoped_refptr( |
| 214 new ReadWriteDataParameters(index, offset, buf_len, truncate))); | 194 new ReadWriteDataParameters(index, offset, buf_len, truncate))); |
| 215 } | 195 } |
| 216 | 196 |
| 217 int result = InternalWriteData(index, offset, buf, buf_len, truncate); | 197 int result = InternalWriteData(index, offset, buf, buf_len, truncate); |
| 218 | 198 |
| 219 if (net_log_.IsLoggingAllEvents()) { | 199 if (net_log_.IsLoggingAllEvents()) { |
| 220 net_log_.EndEvent( | 200 net_log_.EndEvent( |
| 221 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 201 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 222 make_scoped_refptr(new ReadWriteCompleteParameters(result))); | 202 make_scoped_refptr(new ReadWriteCompleteParameters(result))); |
| 223 } | 203 } |
| 224 return result; | 204 return result; |
| 225 } | 205 } |
| 226 | 206 |
| 227 int MemEntryImpl::WriteData( | |
| 228 int index, int offset, net::IOBuffer* buf, int buf_len, | |
| 229 const net::CompletionCallback& completion_callback, bool truncate) { | |
| 230 if (net_log_.IsLoggingAllEvents()) { | |
| 231 net_log_.BeginEvent( | |
| 232 net::NetLog::TYPE_ENTRY_WRITE_DATA, | |
| 233 make_scoped_refptr( | |
| 234 new ReadWriteDataParameters(index, offset, buf_len, truncate))); | |
| 235 } | |
| 236 | |
| 237 int result = InternalWriteData(index, offset, buf, buf_len, truncate); | |
| 238 | |
| 239 if (net_log_.IsLoggingAllEvents()) { | |
| 240 net_log_.EndEvent( | |
| 241 net::NetLog::TYPE_ENTRY_WRITE_DATA, | |
| 242 make_scoped_refptr(new ReadWriteCompleteParameters(result))); | |
| 243 } | |
| 244 return result; | |
| 245 } | |
| 246 | |
| 247 int MemEntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 207 int MemEntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 248 net::OldCompletionCallback* completion_callback
) { | 208 net::OldCompletionCallback* completion_callback
) { |
| 249 if (net_log_.IsLoggingAllEvents()) { | 209 if (net_log_.IsLoggingAllEvents()) { |
| 250 net_log_.BeginEvent( | 210 net_log_.BeginEvent( |
| 251 net::NetLog::TYPE_SPARSE_READ, | 211 net::NetLog::TYPE_SPARSE_READ, |
| 252 make_scoped_refptr( | 212 make_scoped_refptr( |
| 253 new SparseOperationParameters(offset, buf_len))); | 213 new SparseOperationParameters(offset, buf_len))); |
| 254 } | 214 } |
| 255 int result = InternalReadSparseData(offset, buf, buf_len); | 215 int result = InternalReadSparseData(offset, buf, buf_len); |
| 256 if (net_log_.IsLoggingAllEvents()) | 216 if (net_log_.IsLoggingAllEvents()) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 scanned_len += kMaxSparseEntrySize - current_child_offset; | 615 scanned_len += kMaxSparseEntrySize - current_child_offset; |
| 656 } | 616 } |
| 657 return scanned_len; | 617 return scanned_len; |
| 658 } | 618 } |
| 659 | 619 |
| 660 void MemEntryImpl::DetachChild(int child_id) { | 620 void MemEntryImpl::DetachChild(int child_id) { |
| 661 children_->erase(child_id); | 621 children_->erase(child_id); |
| 662 } | 622 } |
| 663 | 623 |
| 664 } // namespace disk_cache | 624 } // namespace disk_cache |
| OLD | NEW |