Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: content/browser/appcache/appcache_response.cc

Issue 2858133002: Add uma stats to help evaluate the impact of changes to the quota allocation logic. (Closed)
Patch Set: macros Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/appcache/appcache_response.h" 5 #include "content/browser/appcache/appcache_response.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/numerics/safe_math.h" 14 #include "base/numerics/safe_math.h"
15 #include "base/pickle.h" 15 #include "base/pickle.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "content/browser/appcache/appcache_storage.h" 19 #include "content/browser/appcache/appcache_storage.h"
20 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
21 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "storage/common/storage_histograms.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 // Disk cache entry data indices. 29 // Disk cache entry data indices.
29 enum { kResponseInfoIndex, kResponseContentIndex, kResponseMetadataIndex }; 30 enum { kResponseInfoIndex, kResponseContentIndex, kResponseMetadataIndex };
30 31
31 // An IOBuffer that wraps a pickle's data. Ownership of the 32 // An IOBuffer that wraps a pickle's data. Ownership of the
32 // pickle is transfered to the WrappedPickleIOBuffer object. 33 // pickle is transfered to the WrappedPickleIOBuffer object.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 HttpResponseInfoIOBuffer::HttpResponseInfoIOBuffer() 74 HttpResponseInfoIOBuffer::HttpResponseInfoIOBuffer()
74 : response_data_size(kUnkownResponseDataSize) {} 75 : response_data_size(kUnkownResponseDataSize) {}
75 76
76 HttpResponseInfoIOBuffer::HttpResponseInfoIOBuffer(net::HttpResponseInfo* info) 77 HttpResponseInfoIOBuffer::HttpResponseInfoIOBuffer(net::HttpResponseInfo* info)
77 : http_info(info), response_data_size(kUnkownResponseDataSize) {} 78 : http_info(info), response_data_size(kUnkownResponseDataSize) {}
78 79
79 HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {} 80 HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {}
80 81
81 // AppCacheDiskCacheInterface ---------------------------------------- 82 // AppCacheDiskCacheInterface ----------------------------------------
82 83
83 AppCacheDiskCacheInterface::AppCacheDiskCacheInterface() 84 AppCacheDiskCacheInterface::AppCacheDiskCacheInterface(const char* uma_name)
84 : weak_factory_(this) {} 85 : uma_name_(uma_name), weak_factory_(this) {}
85 86
86 base::WeakPtr<AppCacheDiskCacheInterface> 87 base::WeakPtr<AppCacheDiskCacheInterface>
87 AppCacheDiskCacheInterface::GetWeakPtr() { 88 AppCacheDiskCacheInterface::GetWeakPtr() {
88 return weak_factory_.GetWeakPtr(); 89 return weak_factory_.GetWeakPtr();
89 } 90 }
90 91
91 AppCacheDiskCacheInterface::~AppCacheDiskCacheInterface() {} 92 AppCacheDiskCacheInterface::~AppCacheDiskCacheInterface() {}
92 93
93 // AppCacheResponseIO ---------------------------------------------- 94 // AppCacheResponseIO ----------------------------------------------
94 95
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 info_buffer_->http_info->metadata = new net::IOBufferWithSize( 287 info_buffer_->http_info->metadata = new net::IOBufferWithSize(
287 base::checked_cast<size_t>(metadata_size)); 288 base::checked_cast<size_t>(metadata_size));
288 ReadRaw(kResponseMetadataIndex, 0, 289 ReadRaw(kResponseMetadataIndex, 0,
289 info_buffer_->http_info->metadata.get(), metadata_size); 290 info_buffer_->http_info->metadata.get(), metadata_size);
290 return; 291 return;
291 } 292 }
292 } else { 293 } else {
293 read_position_ += result; 294 read_position_ += result;
294 } 295 }
295 } 296 }
297 if (result > 0 && disk_cache_)
298 storage::RecordBytesRead(disk_cache_->uma_name(), result);
296 InvokeUserCompletionCallback(result); 299 InvokeUserCompletionCallback(result);
300 // Note: |this| may have been deleted by the completion callback.
297 } 301 }
298 302
299 void AppCacheResponseReader::OnOpenEntryComplete() { 303 void AppCacheResponseReader::OnOpenEntryComplete() {
300 if (!entry_) { 304 if (!entry_) {
301 ScheduleIOCompletionCallback(net::ERR_CACHE_MISS); 305 ScheduleIOCompletionCallback(net::ERR_CACHE_MISS);
302 return; 306 return;
303 } 307 }
304 if (info_buffer_.get()) 308 if (info_buffer_.get())
305 ContinueReadInfo(); 309 ContinueReadInfo();
306 else 310 else
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 382 }
379 383
380 void AppCacheResponseWriter::OnIOComplete(int result) { 384 void AppCacheResponseWriter::OnIOComplete(int result) {
381 if (result >= 0) { 385 if (result >= 0) {
382 DCHECK(write_amount_ == result); 386 DCHECK(write_amount_ == result);
383 if (!info_buffer_.get()) 387 if (!info_buffer_.get())
384 write_position_ += result; 388 write_position_ += result;
385 else 389 else
386 info_size_ = result; 390 info_size_ = result;
387 } 391 }
392 if (result > 0 && disk_cache_)
393 storage::RecordBytesWritten(disk_cache_->uma_name(), result);
388 InvokeUserCompletionCallback(result); 394 InvokeUserCompletionCallback(result);
395 // Note: |this| may have been deleted by the completion callback.
389 } 396 }
390 397
391 void AppCacheResponseWriter::CreateEntryIfNeededAndContinue() { 398 void AppCacheResponseWriter::CreateEntryIfNeededAndContinue() {
392 int rv; 399 int rv;
393 AppCacheDiskCacheInterface::Entry** entry_ptr = NULL; 400 AppCacheDiskCacheInterface::Entry** entry_ptr = NULL;
394 if (entry_) { 401 if (entry_) {
395 creation_phase_ = NO_ATTEMPT; 402 creation_phase_ = NO_ATTEMPT;
396 rv = net::OK; 403 rv = net::OK;
397 } else if (!disk_cache_) { 404 } else if (!disk_cache_) {
398 creation_phase_ = NO_ATTEMPT; 405 creation_phase_ = NO_ATTEMPT;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 void AppCacheResponseMetadataWriter::OnOpenEntryComplete() { 489 void AppCacheResponseMetadataWriter::OnOpenEntryComplete() {
483 if (!entry_) { 490 if (!entry_) {
484 ScheduleIOCompletionCallback(net::ERR_FAILED); 491 ScheduleIOCompletionCallback(net::ERR_FAILED);
485 return; 492 return;
486 } 493 }
487 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); 494 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_);
488 } 495 }
489 496
490 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { 497 void AppCacheResponseMetadataWriter::OnIOComplete(int result) {
491 DCHECK(result < 0 || write_amount_ == result); 498 DCHECK(result < 0 || write_amount_ == result);
499 if (result > 0 && disk_cache_)
500 storage::RecordBytesWritten(disk_cache_->uma_name(), result);
492 InvokeUserCompletionCallback(result); 501 InvokeUserCompletionCallback(result);
502 // Note: |this| may have been deleted by the completion callback.
493 } 503 }
494 504
495 } // namespace content 505 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_response.h ('k') | content/browser/cache_storage/cache_storage_blob_to_disk_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698