Commit 1cd71de0 authored by Sophie Chang's avatar Sophie Chang Committed by Commit Bot

Record local histogram when component hints are updated

Bug: 986438
Change-Id: Ie2c45b4b192c97f106ffa157f7ab1dcce47a8e6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719408
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681107}
parent 47ef98b7
......@@ -29,6 +29,9 @@ void MaybePopulateProcessHintsComponentResult(
} // namespace
const char kComponentHintsUpdatedResultHistogramString[] =
"OptimizationGuide.UpdateComponentHints.Result";
void RecordProcessHintsComponentResult(ProcessHintsComponentResult result) {
UMA_HISTOGRAM_ENUMERATION(kProcessHintsComponentResultHistogramString,
result);
......
......@@ -13,6 +13,10 @@ namespace optimization_guide {
struct HintsComponentInfo;
// The local histogram used to record that the component hints are stored in
// the cache and are ready for use.
extern const char kComponentHintsUpdatedResultHistogramString[];
// Enumerates the possible outcomes of processing the hints component.
//
// Used in UMA histograms, so the order of enumerators should not be changed.
......
......@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/rand_util.h"
#include "base/task/post_task.h"
#include "base/task_runner_util.h"
......@@ -15,6 +16,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "components/optimization_guide/hint_cache_store.h"
#include "components/optimization_guide/hints_component_info.h"
#include "components/optimization_guide/hints_component_util.h"
#include "components/optimization_guide/hints_fetcher.h"
#include "components/optimization_guide/optimization_guide_features.h"
#include "components/optimization_guide/optimization_guide_prefs.h"
......@@ -328,6 +330,13 @@ void PreviewsOptimizationGuide::OnHintsUpdated(
base::OnceClosure update_closure) {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
DCHECK(pref_service_);
// Record the result of updating the hints. This is used as a signal for the
// hints being fully processed in release tools and testing.
LOCAL_HISTOGRAM_BOOLEAN(
optimization_guide::kComponentHintsUpdatedResultHistogramString,
hints_ != nullptr);
if (!update_closure.is_null())
std::move(update_closure).Run();
......
......@@ -244,12 +244,21 @@ class PreviewsOptimizationGuideTest
void ProcessHints(const optimization_guide::proto::Configuration& config,
const std::string& version) {
base::HistogramTester histogram_tester;
optimization_guide::HintsComponentInfo info(
base::Version(version),
temp_dir().Append(FILE_PATH_LITERAL("somefile.pb")));
ASSERT_NO_FATAL_FAILURE(WriteConfigToFile(config, info.path));
base::RunLoop run_loop;
guide_->ListenForNextUpdateForTesting(run_loop.QuitClosure());
guide_->OnHintsComponentAvailable(info);
RunUntilIdle();
run_loop.Run();
// Check for histogram to ensure that we do not remove this histogram since
// it's relied on in release tools.
histogram_tester.ExpectTotalCount(
"OptimizationGuide.UpdateComponentHints.Result", 1);
}
void EnableDataSaver() {
......
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