| 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 |
| 188 int MemEntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, | 208 int MemEntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, |
| 189 int buf_len, net::OldCompletionCallback* completion_callback, bool truncate)
{ | 209 int buf_len, net::OldCompletionCallback* completion_callback, bool truncate)
{ |
| 190 if (net_log_.IsLoggingAllEvents()) { | 210 if (net_log_.IsLoggingAllEvents()) { |
| 191 net_log_.BeginEvent( | 211 net_log_.BeginEvent( |
| 192 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 212 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 193 make_scoped_refptr( | 213 make_scoped_refptr( |
| 194 new ReadWriteDataParameters(index, offset, buf_len, truncate))); | 214 new ReadWriteDataParameters(index, offset, buf_len, truncate))); |
| 195 } | 215 } |
| 196 | 216 |
| 197 int result = InternalWriteData(index, offset, buf, buf_len, truncate); | 217 int result = InternalWriteData(index, offset, buf, buf_len, truncate); |
| 198 | 218 |
| 199 if (net_log_.IsLoggingAllEvents()) { | 219 if (net_log_.IsLoggingAllEvents()) { |
| 200 net_log_.EndEvent( | 220 net_log_.EndEvent( |
| 201 net::NetLog::TYPE_ENTRY_WRITE_DATA, | 221 net::NetLog::TYPE_ENTRY_WRITE_DATA, |
| 202 make_scoped_refptr(new ReadWriteCompleteParameters(result))); | 222 make_scoped_refptr(new ReadWriteCompleteParameters(result))); |
| 203 } | 223 } |
| 204 return result; | 224 return result; |
| 205 } | 225 } |
| 206 | 226 |
| 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 |
| 207 int MemEntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, | 247 int MemEntryImpl::ReadSparseData(int64 offset, net::IOBuffer* buf, int buf_len, |
| 208 net::OldCompletionCallback* completion_callback
) { | 248 net::OldCompletionCallback* completion_callback
) { |
| 209 if (net_log_.IsLoggingAllEvents()) { | 249 if (net_log_.IsLoggingAllEvents()) { |
| 210 net_log_.BeginEvent( | 250 net_log_.BeginEvent( |
| 211 net::NetLog::TYPE_SPARSE_READ, | 251 net::NetLog::TYPE_SPARSE_READ, |
| 212 make_scoped_refptr( | 252 make_scoped_refptr( |
| 213 new SparseOperationParameters(offset, buf_len))); | 253 new SparseOperationParameters(offset, buf_len))); |
| 214 } | 254 } |
| 215 int result = InternalReadSparseData(offset, buf, buf_len); | 255 int result = InternalReadSparseData(offset, buf, buf_len); |
| 216 if (net_log_.IsLoggingAllEvents()) | 256 if (net_log_.IsLoggingAllEvents()) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 scanned_len += kMaxSparseEntrySize - current_child_offset; | 655 scanned_len += kMaxSparseEntrySize - current_child_offset; |
| 616 } | 656 } |
| 617 return scanned_len; | 657 return scanned_len; |
| 618 } | 658 } |
| 619 | 659 |
| 620 void MemEntryImpl::DetachChild(int child_id) { | 660 void MemEntryImpl::DetachChild(int child_id) { |
| 621 children_->erase(child_id); | 661 children_->erase(child_id); |
| 622 } | 662 } |
| 623 | 663 |
| 624 } // namespace disk_cache | 664 } // namespace disk_cache |
| OLD | NEW |