OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/simple/simple_index.h" | 5 #include "net/disk_cache/simple/simple_index.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 uint64 EntryMetadata::GetEntrySize() const { | 114 uint64 EntryMetadata::GetEntrySize() const { |
115 return entry_size_; | 115 return entry_size_; |
116 } | 116 } |
117 | 117 |
118 void EntryMetadata::SetEntrySize(uint64 entry_size) { | 118 void EntryMetadata::SetEntrySize(uint64 entry_size) { |
119 entry_size_ = base::checked_cast<int32>(entry_size); | 119 entry_size_ = base::checked_cast<int32>(entry_size); |
120 } | 120 } |
121 | 121 |
122 void EntryMetadata::Serialize(Pickle* pickle) const { | 122 void EntryMetadata::Serialize(base::Pickle* pickle) const { |
123 DCHECK(pickle); | 123 DCHECK(pickle); |
124 int64 internal_last_used_time = GetLastUsedTime().ToInternalValue(); | 124 int64 internal_last_used_time = GetLastUsedTime().ToInternalValue(); |
125 pickle->WriteInt64(internal_last_used_time); | 125 pickle->WriteInt64(internal_last_used_time); |
126 pickle->WriteUInt64(entry_size_); | 126 pickle->WriteUInt64(entry_size_); |
127 } | 127 } |
128 | 128 |
129 bool EntryMetadata::Deserialize(PickleIterator* it) { | 129 bool EntryMetadata::Deserialize(base::PickleIterator* it) { |
130 DCHECK(it); | 130 DCHECK(it); |
131 int64 tmp_last_used_time; | 131 int64 tmp_last_used_time; |
132 uint64 tmp_entry_size; | 132 uint64 tmp_entry_size; |
133 if (!it->ReadInt64(&tmp_last_used_time) || !it->ReadUInt64(&tmp_entry_size) || | 133 if (!it->ReadInt64(&tmp_last_used_time) || !it->ReadUInt64(&tmp_entry_size) || |
134 tmp_entry_size > static_cast<uint64>(std::numeric_limits<int32>::max())) | 134 tmp_entry_size > static_cast<uint64>(std::numeric_limits<int32>::max())) |
135 return false; | 135 return false; |
136 SetLastUsedTime(base::Time::FromInternalValue(tmp_last_used_time)); | 136 SetLastUsedTime(base::Time::FromInternalValue(tmp_last_used_time)); |
137 entry_size_ = static_cast<int32>(tmp_entry_size); | 137 entry_size_ = static_cast<int32>(tmp_entry_size); |
138 return true; | 138 return true; |
139 } | 139 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 start - last_write_to_disk_); | 471 start - last_write_to_disk_); |
472 } | 472 } |
473 } | 473 } |
474 last_write_to_disk_ = start; | 474 last_write_to_disk_ = start; |
475 | 475 |
476 index_file_->WriteToDisk(entries_set_, cache_size_, | 476 index_file_->WriteToDisk(entries_set_, cache_size_, |
477 start, app_on_background_, base::Closure()); | 477 start, app_on_background_, base::Closure()); |
478 } | 478 } |
479 | 479 |
480 } // namespace disk_cache | 480 } // namespace disk_cache |
OLD | NEW |