From 97a03d29e71a9301f4b2454740602ccd3d430551 Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Sat, 7 Jan 2012 02:45:46 +0100 Subject: [PATCH] Bug 716146 - Telemetry - close disk cache output stream --- netwerk/cache/nsDiskCacheStreams.cpp | 25 +++++++++++++++++++ .../telemetry/TelemetryHistograms.h | 4 +++ 2 files changed, 29 insertions(+) diff --git a/netwerk/cache/nsDiskCacheStreams.cpp b/netwerk/cache/nsDiskCacheStreams.cpp index c9a0d05f376..586dce9225d 100644 --- a/netwerk/cache/nsDiskCacheStreams.cpp +++ b/netwerk/cache/nsDiskCacheStreams.cpp @@ -45,6 +45,9 @@ #include "nsCacheService.h" #include "mozilla/FileUtils.h" #include "nsIDiskCacheStreamInternal.h" +#include "nsThreadUtils.h" +#include "mozilla/Telemetry.h" +#include "mozilla/TimeStamp.h" @@ -231,22 +234,44 @@ nsDiskCacheOutputStream::~nsDiskCacheOutputStream() NS_IMETHODIMP nsDiskCacheOutputStream::Close() { + mozilla::TimeStamp start = mozilla::TimeStamp::Now(); + if (!mClosed) { mClosed = true; // tell parent streamIO we are closing mStreamIO->CloseOutputStream(this); } + + mozilla::Telemetry::ID id; + if (NS_IsMainThread()) + id = mozilla::Telemetry::NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_MAIN_THREAD; + else + id = mozilla::Telemetry::NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE; + + mozilla::Telemetry::AccumulateTimeDelta(id, start); + return NS_OK; } NS_IMETHODIMP nsDiskCacheOutputStream::CloseInternal() { + mozilla::TimeStamp start = mozilla::TimeStamp::Now(); + if (!mClosed) { mClosed = true; // tell parent streamIO we are closing mStreamIO->CloseOutputStreamInternal(this); } + + mozilla::Telemetry::ID id; + if (NS_IsMainThread()) + id = mozilla::Telemetry::NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_INTERNAL_MAIN_THREAD; + else + id = mozilla::Telemetry::NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_INTERNAL; + + mozilla::Telemetry::AccumulateTimeDelta(id, start); + return NS_OK; } diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 8f0c96a55f2..b4f72ba53ed 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -253,6 +253,10 @@ HISTOGRAM(NETWORK_DISK_CACHE_DELETEDIR, 1, 10000, 10, EXPONENTIAL, "Time spent d HISTOGRAM(NETWORK_DISK_CACHE_DELETEDIR_SHUTDOWN, 1, 10000, 10, EXPONENTIAL, "Time spent during showdown stopping thread deleting old disk cache (ms)") HISTOGRAM(NETWORK_DISK_CACHE_SHUTDOWN, 1, 10000, 10, EXPONENTIAL, "Total Time spent (ms) during disk cache showdown") HISTOGRAM(NETWORK_DISK_CACHE_SHUTDOWN_CLEAR_PRIVATE, 1, 10000, 10, EXPONENTIAL, "Time spent (ms) during showdown deleting disk cache for 'clear private data' option") +HISTOGRAM(NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE, 1, 10000, 10, EXPONENTIAL, "Time spent in nsDiskCacheOutputStream::Close() on non-main thread (ms)") +HISTOGRAM(NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_MAIN_THREAD, 1, 10000, 10, EXPONENTIAL, "Time spent in nsDiskCacheOutputStream::Close() on the main thread (ms)") +HISTOGRAM(NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_INTERNAL, 1, 10000, 10, EXPONENTIAL, "Time spent in nsDiskCacheOutputStream::CloseInternal() on non-main thread (ms)") +HISTOGRAM(NETWORK_DISK_CACHE_OUTPUT_STREAM_CLOSE_INTERNAL_MAIN_THREAD, 1, 10000, 10, EXPONENTIAL, "Time spent in nsDiskCacheOutputStream::CloseInternal on the main thread (ms)") /** * Url-Classifier telemetry