| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/entry_impl.h" | 5 #include "net/disk_cache/entry_impl.h" |
| 6 | 6 |
| 7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 entry_->Release(); | 57 entry_->Release(); |
| 58 delete this; | 58 delete this; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SyncCallback::Discard() { | 61 void SyncCallback::Discard() { |
| 62 callback_ = NULL; | 62 callback_ = NULL; |
| 63 buf_ = NULL; | 63 buf_ = NULL; |
| 64 OnFileIOComplete(0); | 64 OnFileIOComplete(0); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Clears buffer before offset and after valid_len, knowing that the size of | |
| 68 // buffer is kMaxBlockSize. | |
| 69 void ClearInvalidData(char* buffer, int offset, int valid_len) { | |
| 70 DCHECK_GE(offset, 0); | |
| 71 DCHECK_GE(valid_len, 0); | |
| 72 DCHECK(disk_cache::kMaxBlockSize >= offset + valid_len); | |
| 73 if (offset) | |
| 74 memset(buffer, 0, offset); | |
| 75 int end = disk_cache::kMaxBlockSize - offset - valid_len; | |
| 76 if (end) | |
| 77 memset(buffer + offset + valid_len, 0, end); | |
| 78 } | |
| 79 | |
| 80 const int kMaxBufferSize = 1024 * 1024; // 1 MB. | 67 const int kMaxBufferSize = 1024 * 1024; // 1 MB. |
| 81 | 68 |
| 82 } // namespace | 69 } // namespace |
| 83 | 70 |
| 84 namespace disk_cache { | 71 namespace disk_cache { |
| 85 | 72 |
| 86 // This class handles individual memory buffers that store data before it is | 73 // This class handles individual memory buffers that store data before it is |
| 87 // sent to disk. The buffer can start at any offset, but if we try to write to | 74 // sent to disk. The buffer can start at any offset, but if we try to write to |
| 88 // anywhere in the first 16KB of the file (kMaxBlockSize), we set the offset to | 75 // anywhere in the first 16KB of the file (kMaxBlockSize), we set the offset to |
| 89 // zero. The buffer grows up to a size determined by the backend, to keep the | 76 // zero. The buffer grows up to a size determined by the backend, to keep the |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), | 1259 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), |
| 1273 entry_.address().value(), node_.address().value()); | 1260 entry_.address().value(), node_.address().value()); |
| 1274 | 1261 |
| 1275 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], | 1262 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], |
| 1276 entry_.Data()->data_addr[1], entry_.Data()->long_key); | 1263 entry_.Data()->data_addr[1], entry_.Data()->long_key); |
| 1277 | 1264 |
| 1278 Trace(" doomed: %d 0x%x", doomed_, dirty); | 1265 Trace(" doomed: %d 0x%x", doomed_, dirty); |
| 1279 } | 1266 } |
| 1280 | 1267 |
| 1281 } // namespace disk_cache | 1268 } // namespace disk_cache |
| OLD | NEW |