diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 19:01:03 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-06 19:01:03 +0000 |
commit | 5cc9eeb8555cce33bf9f098b207fc9b082a6f408 (patch) | |
tree | 96a259ffb2f7482ff739a28f3b90f68e91d5d383 /net/disk_cache/sparse_control.cc | |
parent | 0b0c493346da0268d3e25ebafaa5a0eae6bc46ee (diff) | |
download | chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.zip chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.tar.gz chromium_src-5cc9eeb8555cce33bf9f098b207fc9b082a6f408.tar.bz2 |
First pass at adding http/backend cache events to the NetLog.
Adds sources and events for ActiveCacheEntry and EntryImpl
objects, as well as adding cache read/write events to
HttpCacheTransactions. Most new read/write events are
only logged when NetLog logging mode is set to log all events.
Also, net-internals now merges begin and end events that have
parameters, as long as only one of them has parameters.
I think this increases readability, at the cost of making
it a little more difficult to follow timings with just the "st"
values.
BUG=59382
TEST=none yet, other than updates to existing tests.
Originally applied: http://src.chromium.org/viewvc/chrome?view=rev&revision=70618
Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=70619
Fixed and trying again...
Review URL: http://codereview.chromium.org/6125001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/sparse_control.cc')
-rw-r--r-- | net/disk_cache/sparse_control.cc | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/net/disk_cache/sparse_control.cc b/net/disk_cache/sparse_control.cc index 32f44ab..ebc8250 100644 --- a/net/disk_cache/sparse_control.cc +++ b/net/disk_cache/sparse_control.cc @@ -138,6 +138,30 @@ void ChildrenDeleter::DeleteChildren() { this, &ChildrenDeleter::DeleteChildren)); } +// Logs the end event for |operation|, if all events are being logged. +void LogOperationEnd(const net::BoundNetLog& net_log, + disk_cache::SparseControl::SparseOperation operation, + int result) { + if (net_log.IsLoggingAllEvents()) { + net::NetLog::EventType event_type; + switch (operation) { + case disk_cache::SparseControl::kReadOperation: + event_type = net::NetLog::TYPE_SPARSE_CONTROL_READ; + break; + case disk_cache::SparseControl::kWriteOperation: + event_type = net::NetLog::TYPE_SPARSE_CONTROL_WRITE; + break; + case disk_cache::SparseControl::kGetRangeOperation: + event_type = net::NetLog::TYPE_SPARSE_CONTROL_GET_RANGE; + break; + default: + NOTREACHED(); + return; + } + net_log.EndEventWithNetErrorCode(event_type, result); + } +} + } // namespace. namespace disk_cache { @@ -223,6 +247,7 @@ int SparseControl::StartIO(SparseOperation op, int64 offset, net::IOBuffer* buf, finished_ = false; abort_ = false; + entry_->net_log().BeginEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); DoChildrenIO(); if (!pending_) { @@ -610,8 +635,11 @@ void SparseControl::InitChildData() { void SparseControl::DoChildrenIO() { while (DoChildIO()) continue; - if (pending_ && finished_) - DoUserCallback(); + if (finished_) { + entry_->net_log().EndEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); + if (pending_) + DoUserCallback(); + } } bool SparseControl::DoChildIO() { @@ -632,14 +660,32 @@ bool SparseControl::DoChildIO() { int rv = 0; switch (operation_) { case kReadOperation: + if (entry_->net_log().IsLoggingAllEvents()) { + entry_->net_log().BeginEvent( + net::NetLog::TYPE_SPARSE_CONTROL_READ, + make_scoped_refptr(new net::NetLogSourceParameter( + "source_dependency", + child_->net_log().source()))); + } rv = child_->ReadDataImpl(kSparseData, child_offset_, user_buf_, child_len_, callback); break; case kWriteOperation: + if (entry_->net_log().IsLoggingAllEvents()) { + entry_->net_log().BeginEvent( + net::NetLog::TYPE_SPARSE_CONTROL_WRITE, + make_scoped_refptr(new net::NetLogSourceParameter( + "source_dependency", + child_->net_log().source()))); + } rv = child_->WriteDataImpl(kSparseData, child_offset_, user_buf_, child_len_, callback, false); break; case kGetRangeOperation: + if (entry_->net_log().IsLoggingAllEvents()) { + entry_->net_log().BeginEvent(net::NetLog::TYPE_SPARSE_CONTROL_GET_RANGE, + NULL); + } rv = DoGetAvailableRange(); break; default: @@ -712,6 +758,7 @@ int SparseControl::DoGetAvailableRange() { } void SparseControl::DoChildIOCompleted(int result) { + LogOperationEnd(entry_->net_log(), operation_, result); if (result < 0) { // We fail the whole operation if we encounter an error. result_ = result; @@ -737,6 +784,8 @@ void SparseControl::OnChildIOCompleted(int result) { // We'll return the current result of the operation, which may be less than // the bytes to read or write, but the user cancelled the operation. abort_ = false; + entry_->net_log().AddEvent(net::NetLog::TYPE_CANCELLED, NULL); + entry_->net_log().EndEvent(net::NetLog::TYPE_SPARSE_CONTROL, NULL); DoUserCallback(); return DoAbortCallbacks(); } |