Commit 6dacf7c3 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

[blink] Record filereader metrics using //base/metrics helpers.

This also converts the various metric enums to be scoped enums, which
allows:
- clang to enforce kMaxValue correctness
- autodeduction of the max value by UMA_HISTOGRAM_ENUMERATION.

Bug: 742517, 1047547
Change-Id: I3d7c4476d0001fd9984527918f7c2494332653a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506359
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822089}
parent 6cc853a2
......@@ -47,7 +47,6 @@
#include "third_party/blink/renderer/core/loader/threadable_loader_client.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/platform/blob/blob_url.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_initiator_type_names.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_error.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
......@@ -213,14 +212,12 @@ void FileReaderLoader::Cleanup() {
}
void FileReaderLoader::Failed(FileErrorCode error_code, FailureType type) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, failure_histogram,
("Storage.Blob.FileReaderLoader.FailureType",
static_cast<int>(FailureType::kCount)));
// If an error was already reported, don't report this error again.
if (error_code_ != FileErrorCode::kOK)
return;
error_code_ = error_code;
failure_histogram.Count(static_cast<int>(type));
base::UmaHistogramEnumeration("Storage.Blob.FileReaderLoader.FailureType",
type);
Cleanup();
if (client_)
client_->DidFail(error_code_);
......
......@@ -125,7 +125,7 @@ class CORE_EXPORT FileReaderLoader : public mojom::blink::BlobReaderClient {
// into this bucket. If there are a large number of errors reported here,
// then there can be a new enumeration reported for mojo pipe errors.
kMojoPipeUnexpectedReadError = 10,
kCount
kMaxValue = kMojoPipeUnexpectedReadError,
};
void Cleanup();
......
......@@ -32,6 +32,7 @@
#include <memory>
#include "base/metrics/histogram_functions.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/fileapi/file_error.h"
......@@ -39,7 +40,6 @@
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
namespace blink {
......@@ -51,7 +51,7 @@ enum class WorkerType {
DEDICATED_WORKER = 1,
SHARED_WORKER = 2,
SERVICE_WORKER = 3,
MAX
kMaxValue = SERVICE_WORKER,
};
} // namespace
......@@ -64,10 +64,7 @@ FileReaderSync::FileReaderSync(ExecutionContext* context)
type = WorkerType::SHARED_WORKER;
else if (context->IsServiceWorkerGlobalScope())
type = WorkerType::SERVICE_WORKER;
DEFINE_THREAD_SAFE_STATIC_LOCAL(
EnumerationHistogram, worker_type_histogram,
("FileReaderSync.WorkerType", static_cast<int>(WorkerType::MAX)));
worker_type_histogram.Count(static_cast<int>(type));
base::UmaHistogramEnumeration("FileReaderSync.WorkerType", type);
}
DOMArrayBuffer* FileReaderSync::readAsArrayBuffer(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment