diff options
author | dmurph <dmurph@chromium.org> | 2015-03-13 17:45:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-14 00:45:52 +0000 |
commit | 0fb0e948b24e906e844d4c053bab957bacd93a84 (patch) | |
tree | f8159c43f5e214c5a3acfc2f5cefafcceac27d52 /storage | |
parent | d289121eefd37f4601b9eba51edfbff99b58d1ae (diff) | |
download | chromium_src-0fb0e948b24e906e844d4c053bab957bacd93a84.zip chromium_src-0fb0e948b24e906e844d4c053bab957bacd93a84.tar.gz chromium_src-0fb0e948b24e906e844d4c053bab957bacd93a84.tar.bz2 |
[Storage] Added tracing for blob creation and reading.
BUG=375297
Review URL: https://codereview.chromium.org/992753002
Cr-Commit-Position: refs/heads/master@{#320623}
Diffstat (limited to 'storage')
-rw-r--r-- | storage/browser/blob/blob_data_snapshot.h | 2 | ||||
-rw-r--r-- | storage/browser/blob/blob_storage_context.cc | 4 | ||||
-rw-r--r-- | storage/browser/blob/blob_url_request_job.cc | 30 | ||||
-rw-r--r-- | storage/browser/blob/blob_url_request_job.h | 5 |
4 files changed, 34 insertions, 7 deletions
diff --git a/storage/browser/blob/blob_data_snapshot.h b/storage/browser/blob/blob_data_snapshot.h index 3d6309e..f0d47227 100644 --- a/storage/browser/blob/blob_data_snapshot.h +++ b/storage/browser/blob/blob_data_snapshot.h @@ -37,6 +37,8 @@ class STORAGE_EXPORT BlobDataSnapshot : public base::SupportsUserData::Data { } size_t GetMemoryUsage() const; + const std::string& uuid() const { return uuid_; } + private: friend class BlobDataBuilder; friend class BlobStorageContext; diff --git a/storage/browser/blob/blob_storage_context.cc b/storage/browser/blob/blob_storage_context.cc index b673930..71e8939 100644 --- a/storage/browser/blob/blob_storage_context.cc +++ b/storage/browser/blob/blob_storage_context.cc @@ -14,6 +14,7 @@ #include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" +#include "base/trace_event/trace_event.h" #include "storage/browser/blob/blob_data_builder.h" #include "storage/browser/blob/blob_data_handle.h" #include "url/gurl.h" @@ -92,6 +93,7 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL( scoped_ptr<BlobDataHandle> BlobStorageContext::AddFinishedBlob( BlobDataBuilder* external_builder) { + TRACE_EVENT0("Blob", "Context::AddFinishedBlob"); StartBuildingBlob(external_builder->uuid_); BlobMap::iterator found = blob_map_.find(external_builder->uuid_); DCHECK(found != blob_map_.end()); @@ -163,6 +165,7 @@ void BlobStorageContext::StartBuildingBlob(const std::string& uuid) { void BlobStorageContext::AppendBlobDataItem( const std::string& uuid, const storage::DataElement& ipc_data_element) { + TRACE_EVENT0("Blob", "Context::AppendBlobDataItem"); DCHECK(IsBeingBuilt(uuid)); BlobMap::iterator found = blob_map_.find(uuid); if (found == blob_map_.end()) @@ -202,6 +205,7 @@ void BlobStorageContext::FinishBuildingBlob(const std::string& uuid, UMA_HISTOGRAM_COUNTS("Storage.Blob.TotalSize", total_memory / 1024); UMA_HISTOGRAM_COUNTS("Storage.Blob.TotalUnsharedSize", nonshared_memory / 1024); + TRACE_COUNTER1("Blob", "MemoryStoreUsageBytes", memory_usage_); } void BlobStorageContext::CancelBuildingBlob(const std::string& uuid) { diff --git a/storage/browser/blob/blob_url_request_job.cc b/storage/browser/blob/blob_url_request_job.cc index 8e48563..0c938aa 100644 --- a/storage/browser/blob/blob_url_request_job.cc +++ b/storage/browser/blob/blob_url_request_job.cc @@ -21,6 +21,7 @@ #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" +#include "base/trace_event/trace_event.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/http/http_request_headers.h" @@ -70,6 +71,8 @@ BlobURLRequestJob::BlobURLRequestJob( error_(false), byte_range_set_(false), weak_factory_(this) { + TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobRequest", this, "uuid", + blob_data_->uuid()); DCHECK(file_thread_proxy_.get()); } @@ -163,9 +166,11 @@ void BlobURLRequestJob::SetExtraRequestHeaders( BlobURLRequestJob::~BlobURLRequestJob() { STLDeleteValues(&index_to_reader_); + TRACE_EVENT_ASYNC_END1("Blob", "Request", this, "uuid", blob_data_->uuid()); } void BlobURLRequestJob::DidStart() { + current_file_chunk_number_ = 0; error_ = false; // We only support GET request per the spec. @@ -185,6 +190,8 @@ void BlobURLRequestJob::DidStart() { bool BlobURLRequestJob::AddItemLength(size_t index, int64 item_length) { if (item_length > kint64max - total_size_) { + TRACE_EVENT_ASYNC_END1("Blob", "BlobRequest::CountSize", this, "uuid", + blob_data_->uuid()); NotifyFailure(net::ERR_FAILED); return false; } @@ -197,6 +204,8 @@ bool BlobURLRequestJob::AddItemLength(size_t index, int64 item_length) { } void BlobURLRequestJob::CountSize() { + TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobRequest::CountSize", this, "uuid", + blob_data_->uuid()); pending_get_file_info_count_ = 0; total_size_ = 0; const auto& items = blob_data_->items(); @@ -222,6 +231,8 @@ void BlobURLRequestJob::CountSize() { void BlobURLRequestJob::DidCountSize(int error) { DCHECK(!error_); + TRACE_EVENT_ASYNC_END1("Blob", "BlobRequest::CountSize", this, "uuid", + blob_data_->uuid()); // If an error occured, bail out. if (error != net::OK) { @@ -377,6 +388,8 @@ void BlobURLRequestJob::AdvanceBytesRead(int result) { bool BlobURLRequestJob::ReadBytesItem(const BlobDataItem& item, int bytes_to_read) { + TRACE_EVENT1("Blob", "BlobRequest::ReadBytesItem", "uuid", + blob_data_->uuid()); DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read); memcpy(read_buf_->data(), @@ -391,14 +404,17 @@ bool BlobURLRequestJob::ReadFileItem(FileStreamReader* reader, int bytes_to_read) { DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read); DCHECK(reader); - const int result = reader->Read( - read_buf_.get(), - bytes_to_read, - base::Bind(&BlobURLRequestJob::DidReadFile, base::Unretained(this))); + int chunk_number = current_file_chunk_number_++; + TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobRequest::ReadFileItem", this, "uuid", + blob_data_->uuid()); + const int result = + reader->Read(read_buf_.get(), bytes_to_read, + base::Bind(&BlobURLRequestJob::DidReadFile, + base::Unretained(this), chunk_number)); if (result >= 0) { // Data is immediately available. if (GetStatus().is_io_pending()) - DidReadFile(result); + DidReadFile(chunk_number, result); else AdvanceBytesRead(result); return true; @@ -410,7 +426,9 @@ bool BlobURLRequestJob::ReadFileItem(FileStreamReader* reader, return false; } -void BlobURLRequestJob::DidReadFile(int result) { +void BlobURLRequestJob::DidReadFile(int chunk_number, int result) { + TRACE_EVENT_ASYNC_END1("Blob", "BlobRequest::ReadFileItem", this, "uuid", + blob_data_->uuid()); if (result <= 0) { NotifyFailure(net::ERR_FAILED); return; diff --git a/storage/browser/blob/blob_url_request_job.h b/storage/browser/blob/blob_url_request_job.h index cf296b6..3dfc093 100644 --- a/storage/browser/blob/blob_url_request_job.h +++ b/storage/browser/blob/blob_url_request_job.h @@ -73,7 +73,7 @@ class STORAGE_EXPORT BlobURLRequestJob bool ReadBytesItem(const BlobDataItem& item, int bytes_to_read); bool ReadFileItem(FileStreamReader* reader, int bytes_to_read); - void DidReadFile(int result); + void DidReadFile(int chunk_number, int result); void DeleteCurrentFileReader(); int ComputeBytesToRead() const; @@ -114,6 +114,9 @@ class STORAGE_EXPORT BlobURLRequestJob bool byte_range_set_; net::HttpByteRange byte_range_; + // Used to create unique id's for tracing. + int current_file_chunk_number_; + scoped_ptr<net::HttpResponseInfo> response_info_; base::WeakPtrFactory<BlobURLRequestJob> weak_factory_; |