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> |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 int buf_len_p) | 251 int buf_len_p) |
252 : sparse_offset(sparse_offset_p), buf_len(buf_len_p) {} | 252 : sparse_offset(sparse_offset_p), buf_len(buf_len_p) {} |
253 | 253 |
254 // static | 254 // static |
255 void SimpleSynchronousEntry::OpenEntry( | 255 void SimpleSynchronousEntry::OpenEntry( |
256 net::CacheType cache_type, | 256 net::CacheType cache_type, |
257 const FilePath& path, | 257 const FilePath& path, |
258 const std::string& key, | 258 const std::string& key, |
259 const uint64_t entry_hash, | 259 const uint64_t entry_hash, |
260 const bool had_index, | 260 const bool had_index, |
261 const base::TimeTicks& start_time, | |
261 SimpleEntryCreationResults* out_results) { | 262 SimpleEntryCreationResults* out_results) { |
262 base::ElapsedTimer open_time; | 263 base::TimeTicks start_sync_open_entry = base::TimeTicks::Now(); |
264 SIMPLE_CACHE_UMA(TIMES, "QueueLatency.OpenEntry", cache_type, | |
265 (start_sync_open_entry - start_time)); | |
266 | |
263 SimpleSynchronousEntry* sync_entry = | 267 SimpleSynchronousEntry* sync_entry = |
264 new SimpleSynchronousEntry(cache_type, path, key, entry_hash, had_index); | 268 new SimpleSynchronousEntry(cache_type, path, key, entry_hash, had_index); |
265 out_results->result = sync_entry->InitializeForOpen( | 269 out_results->result = sync_entry->InitializeForOpen( |
266 &out_results->entry_stat, &out_results->stream_0_data, | 270 &out_results->entry_stat, &out_results->stream_0_data, |
267 &out_results->stream_0_crc32); | 271 &out_results->stream_0_crc32); |
268 if (out_results->result != net::OK) { | 272 if (out_results->result != net::OK) { |
269 sync_entry->Doom(); | 273 sync_entry->Doom(); |
270 delete sync_entry; | 274 delete sync_entry; |
271 out_results->sync_entry = NULL; | 275 out_results->sync_entry = NULL; |
272 out_results->stream_0_data = NULL; | 276 out_results->stream_0_data = NULL; |
273 return; | 277 return; |
274 } | 278 } |
275 UMA_HISTOGRAM_TIMES("SimpleCache.DiskOpenLatency", open_time.Elapsed()); | 279 UMA_HISTOGRAM_TIMES("SimpleCache.DiskOpenLatency", |
xunjieli
2017/05/02 18:21:29
I think it makes sense for DiskOpenLatency to be s
Maks Orlovich
2017/05/02 19:49:20
This is convincing, thanks. (And suggests that I m
xunjieli
2017/05/02 21:25:18
Acknowledged.
| |
280 base::TimeTicks::Now() - start_sync_open_entry); | |
276 out_results->sync_entry = sync_entry; | 281 out_results->sync_entry = sync_entry; |
277 } | 282 } |
278 | 283 |
279 // static | 284 // static |
280 void SimpleSynchronousEntry::CreateEntry( | 285 void SimpleSynchronousEntry::CreateEntry( |
281 net::CacheType cache_type, | 286 net::CacheType cache_type, |
282 const FilePath& path, | 287 const FilePath& path, |
283 const std::string& key, | 288 const std::string& key, |
284 const uint64_t entry_hash, | 289 const uint64_t entry_hash, |
285 const bool had_index, | 290 const bool had_index, |
291 const base::TimeTicks& start_time, | |
286 SimpleEntryCreationResults* out_results) { | 292 SimpleEntryCreationResults* out_results) { |
287 DCHECK_EQ(entry_hash, GetEntryHashKey(key)); | 293 DCHECK_EQ(entry_hash, GetEntryHashKey(key)); |
294 base::TimeTicks start_sync_create_entry = base::TimeTicks::Now(); | |
295 SIMPLE_CACHE_UMA(TIMES, "QueueLatency.CreateEntry", cache_type, | |
296 (start_sync_create_entry - start_time)); | |
297 | |
288 SimpleSynchronousEntry* sync_entry = | 298 SimpleSynchronousEntry* sync_entry = |
289 new SimpleSynchronousEntry(cache_type, path, key, entry_hash, had_index); | 299 new SimpleSynchronousEntry(cache_type, path, key, entry_hash, had_index); |
290 out_results->result = | 300 out_results->result = |
291 sync_entry->InitializeForCreate(&out_results->entry_stat); | 301 sync_entry->InitializeForCreate(&out_results->entry_stat); |
292 if (out_results->result != net::OK) { | 302 if (out_results->result != net::OK) { |
293 if (out_results->result != net::ERR_FILE_EXISTS) | 303 if (out_results->result != net::ERR_FILE_EXISTS) |
294 sync_entry->Doom(); | 304 sync_entry->Doom(); |
295 delete sync_entry; | 305 delete sync_entry; |
296 out_results->sync_entry = NULL; | 306 out_results->sync_entry = NULL; |
297 return; | 307 return; |
298 } | 308 } |
299 out_results->sync_entry = sync_entry; | 309 out_results->sync_entry = sync_entry; |
310 SIMPLE_CACHE_UMA(TIMES, "DiskCreateLatency", cache_type, | |
311 base::TimeTicks::Now() - start_sync_create_entry); | |
xunjieli
2017/05/02 18:21:29
Same here. Do we care about the failure case?
Maks Orlovich
2017/05/02 19:49:20
Acknowledged.
| |
300 } | 312 } |
301 | 313 |
302 // static | 314 // static |
303 int SimpleSynchronousEntry::DoomEntry(const FilePath& path, | 315 int SimpleSynchronousEntry::DoomEntry(const FilePath& path, |
304 uint64_t entry_hash) { | 316 uint64_t entry_hash) { |
305 const bool deleted_well = DeleteFilesForEntryHash(path, entry_hash); | 317 const bool deleted_well = DeleteFilesForEntryHash(path, entry_hash); |
306 return deleted_well ? net::OK : net::ERR_FAILED; | 318 return deleted_well ? net::OK : net::ERR_FAILED; |
307 } | 319 } |
308 | 320 |
309 // static | 321 // static |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 range.offset = offset; | 1612 range.offset = offset; |
1601 range.length = len; | 1613 range.length = len; |
1602 range.data_crc32 = data_crc32; | 1614 range.data_crc32 = data_crc32; |
1603 range.file_offset = data_file_offset; | 1615 range.file_offset = data_file_offset; |
1604 sparse_ranges_.insert(std::make_pair(offset, range)); | 1616 sparse_ranges_.insert(std::make_pair(offset, range)); |
1605 | 1617 |
1606 return true; | 1618 return true; |
1607 } | 1619 } |
1608 | 1620 |
1609 } // namespace disk_cache | 1621 } // namespace disk_cache |
OLD | NEW |