Chromium Code Reviews| 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_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/hash.h" | 15 #include "base/hash.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/metrics/histogram.h" | |
| 17 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
| 18 #include "base/sha1.h" | 19 #include "base/sha1.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/time/time.h" | |
| 20 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 21 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 22 #include "net/disk_cache/simple/simple_backend_version.h" | 24 #include "net/disk_cache/simple/simple_backend_version.h" |
| 23 #include "net/disk_cache/simple/simple_histogram_macros.h" | 25 #include "net/disk_cache/simple/simple_histogram_macros.h" |
| 24 #include "net/disk_cache/simple/simple_util.h" | 26 #include "net/disk_cache/simple/simple_util.h" |
| 25 #include "third_party/zlib/zlib.h" | 27 #include "third_party/zlib/zlib.h" |
| 26 | 28 |
| 27 using base::File; | 29 using base::File; |
| 28 using base::FilePath; | 30 using base::FilePath; |
| 29 using base::Time; | 31 using base::Time; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 : sparse_offset(sparse_offset_p), | 211 : sparse_offset(sparse_offset_p), |
| 210 buf_len(buf_len_p) {} | 212 buf_len(buf_len_p) {} |
| 211 | 213 |
| 212 // static | 214 // static |
| 213 void SimpleSynchronousEntry::OpenEntry( | 215 void SimpleSynchronousEntry::OpenEntry( |
| 214 net::CacheType cache_type, | 216 net::CacheType cache_type, |
| 215 const FilePath& path, | 217 const FilePath& path, |
| 216 const uint64 entry_hash, | 218 const uint64 entry_hash, |
| 217 bool had_index, | 219 bool had_index, |
| 218 SimpleEntryCreationResults *out_results) { | 220 SimpleEntryCreationResults *out_results) { |
| 221 base::Time open_start_time(base::Time::Now()); | |
|
Deprecated (see juliatuttle)
2015/05/13 20:21:38
Perhaps use TimeTicks? I am under the impression i
Randy Smith (Not in Mondays)
2015/05/13 20:32:52
Oh, good point. I haven't done this in too long,
| |
| 219 SimpleSynchronousEntry* sync_entry = | 222 SimpleSynchronousEntry* sync_entry = |
| 220 new SimpleSynchronousEntry(cache_type, path, "", entry_hash); | 223 new SimpleSynchronousEntry(cache_type, path, "", entry_hash); |
| 221 out_results->result = | 224 out_results->result = |
| 222 sync_entry->InitializeForOpen(had_index, | 225 sync_entry->InitializeForOpen(had_index, |
| 223 &out_results->entry_stat, | 226 &out_results->entry_stat, |
| 224 &out_results->stream_0_data, | 227 &out_results->stream_0_data, |
| 225 &out_results->stream_0_crc32); | 228 &out_results->stream_0_crc32); |
| 226 if (out_results->result != net::OK) { | 229 if (out_results->result != net::OK) { |
| 227 sync_entry->Doom(); | 230 sync_entry->Doom(); |
| 228 delete sync_entry; | 231 delete sync_entry; |
| 229 out_results->sync_entry = NULL; | 232 out_results->sync_entry = NULL; |
| 230 out_results->stream_0_data = NULL; | 233 out_results->stream_0_data = NULL; |
| 231 return; | 234 return; |
| 232 } | 235 } |
| 236 UMA_HISTOGRAM_TIMES("SimpleCache.DiskOpenLatency", | |
|
Deprecated (see juliatuttle)
2015/05/13 20:21:38
This looks good as long as you only care about ope
Randy Smith (Not in Mondays)
2015/05/13 20:32:52
So Bryan and I chatted, and decided we'd be mostly
| |
| 237 base::Time::Now() - open_start_time); | |
| 233 out_results->sync_entry = sync_entry; | 238 out_results->sync_entry = sync_entry; |
| 234 } | 239 } |
| 235 | 240 |
| 236 // static | 241 // static |
| 237 void SimpleSynchronousEntry::CreateEntry( | 242 void SimpleSynchronousEntry::CreateEntry( |
| 238 net::CacheType cache_type, | 243 net::CacheType cache_type, |
| 239 const FilePath& path, | 244 const FilePath& path, |
| 240 const std::string& key, | 245 const std::string& key, |
| 241 const uint64 entry_hash, | 246 const uint64 entry_hash, |
| 242 bool had_index, | 247 bool had_index, |
| (...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 range.offset = offset; | 1432 range.offset = offset; |
| 1428 range.length = len; | 1433 range.length = len; |
| 1429 range.data_crc32 = data_crc32; | 1434 range.data_crc32 = data_crc32; |
| 1430 range.file_offset = data_file_offset; | 1435 range.file_offset = data_file_offset; |
| 1431 sparse_ranges_.insert(std::make_pair(offset, range)); | 1436 sparse_ranges_.insert(std::make_pair(offset, range)); |
| 1432 | 1437 |
| 1433 return true; | 1438 return true; |
| 1434 } | 1439 } |
| 1435 | 1440 |
| 1436 } // namespace disk_cache | 1441 } // namespace disk_cache |
| OLD | NEW |