Commit 9e0b47c5 authored by Quentin Fiard's avatar Quentin Fiard Committed by Commit Bot

Add a service to emit domain mixing metrics based on the Google search activity of the user

Flag-protected by the EmitGoogleSearchDomainMixingMetrics feature which guards the ServiceIsCreatedWithBrowserContext() method of the factory. The service is never explicitly requested, so this is sufficient to guard the creation of the service.

Bug: 825255
Change-Id: Ia62b157ae56edc2806fda0feb214d64be43c0750
Reviewed-on: https://chromium-review.googlesource.com/1087454
Commit-Queue: Quentin Fiard <qfiard@google.com>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568136}
parent 0007c935
...@@ -539,6 +539,10 @@ jumbo_split_static_library("browser") { ...@@ -539,6 +539,10 @@ jumbo_split_static_library("browser") {
"google/google_brand.h", "google/google_brand.h",
"google/google_brand_chromeos.cc", "google/google_brand_chromeos.cc",
"google/google_brand_chromeos.h", "google/google_brand_chromeos.h",
"google/google_search_domain_mixing_metrics_emitter.cc",
"google/google_search_domain_mixing_metrics_emitter.h",
"google/google_search_domain_mixing_metrics_emitter_factory.cc",
"google/google_search_domain_mixing_metrics_emitter_factory.h",
"google/google_url_tracker_factory.cc", "google/google_url_tracker_factory.cc",
"google/google_url_tracker_factory.h", "google/google_url_tracker_factory.h",
"gpu/gpu_mode_manager.cc", "gpu/gpu_mode_manager.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/history/core/browser/domain_mixing_metrics.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_database.h"
#include "components/history/core/browser/history_db_task.h"
#include "content/public/browser/browser_thread.h"
namespace {
class EmitMetricsDBTask : public history::HistoryDBTask {
public:
EmitMetricsDBTask(const base::Time begin_time,
const base::Time end_time,
PrefService* prefs)
: begin_time_(begin_time), end_time_(end_time), prefs_(prefs) {}
bool RunOnDBThread(history::HistoryBackend* backend,
history::HistoryDatabase* db) override {
EmitDomainMixingMetrics(
db->GetGoogleDomainVisitsFromSearchesInRange(
begin_time_ - base::TimeDelta::FromDays(29), end_time_),
begin_time_);
return true;
}
void DoneRunOnMainThread() override {
// Preferences must be set on the main thread.
prefs_->SetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime,
end_time_);
}
private:
const base::Time begin_time_;
const base::Time end_time_;
PrefService* const prefs_;
};
} // namespace
const char GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime[] =
"browser.last_google_search_domain_mixing_metrics_time";
GoogleSearchDomainMixingMetricsEmitter::GoogleSearchDomainMixingMetricsEmitter(
PrefService* prefs,
history::HistoryService* history_service)
: prefs_(prefs),
history_service_(history_service),
ui_thread_task_runner_(content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI)) {}
GoogleSearchDomainMixingMetricsEmitter::
~GoogleSearchDomainMixingMetricsEmitter() {}
// static
void GoogleSearchDomainMixingMetricsEmitter::RegisterProfilePrefs(
PrefRegistrySimple* registry) {
registry->RegisterTimePref(kLastMetricsTime, base::Time());
}
void GoogleSearchDomainMixingMetricsEmitter::Start() {
// Schedule the task to emit domain mixing metrics the next time domain mixing
// metrics will need to be computed.
// If domain mixing metrics have never been computed, we start computing them
// for active days starting now.
base::Time last_domain_mixing_metrics_time =
prefs_->GetTime(kLastMetricsTime);
if (last_domain_mixing_metrics_time.is_null()) {
// Domain mixing metrics were never computed. We start emitting metrics
// from today 4am. This is designed so that the time windows used to compute
// domain mixing are cut at times when the user is likely to be inactive.
last_domain_mixing_metrics_time =
clock_->Now().LocalMidnight() + base::TimeDelta::FromHours(4);
prefs_->SetTime(kLastMetricsTime, last_domain_mixing_metrics_time);
}
ui_thread_task_runner_->PostDelayedTask(
FROM_HERE,
base::BindOnce(&GoogleSearchDomainMixingMetricsEmitter::EmitMetrics,
base::Unretained(this)),
// Delay at least ten seconds to avoid delaying browser startup.
std::max(base::TimeDelta::FromSeconds(10),
last_domain_mixing_metrics_time + base::TimeDelta::FromDays(1) -
clock_->Now()));
}
void GoogleSearchDomainMixingMetricsEmitter::SetClockForTesting(
std::unique_ptr<base::Clock> clock) {
clock_ = std::move(clock);
}
void GoogleSearchDomainMixingMetricsEmitter::SetTimerForTesting(
std::unique_ptr<base::Timer> timer) {
timer_ = std::move(timer);
}
void GoogleSearchDomainMixingMetricsEmitter::SetUIThreadTaskRunnerForTesting(
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) {
ui_thread_task_runner_ = std::move(ui_thread_task_runner);
}
void GoogleSearchDomainMixingMetricsEmitter::EmitMetrics() {
// Preferences must be accessed on the main thread so we look up here the last
// time for which domain mixing metrics were computed.
const base::Time begin_time = prefs_->GetTime(kLastMetricsTime);
// We only process full days of history.
const int days_to_compute = (clock_->Now() - begin_time).InDays();
history_service_->ScheduleDBTask(
FROM_HERE,
std::make_unique<EmitMetricsDBTask>(
begin_time, begin_time + base::TimeDelta::FromDays(days_to_compute),
prefs_),
&task_tracker_);
if (!timer_->IsRunning()) {
// Run the task daily from now on.
timer_->Start(FROM_HERE, base::TimeDelta::FromDays(1),
base::BindRepeating(
&GoogleSearchDomainMixingMetricsEmitter::EmitMetrics,
base::Unretained(this)));
}
}
void GoogleSearchDomainMixingMetricsEmitter::Shutdown() {
task_tracker_.TryCancelAll();
timer_->Stop();
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_H_
#define CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_H_
#include <memory>
#include "base/memory/scoped_refptr.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/timer/timer.h"
#include "components/history/core/browser/history_service.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
// Emits domain mixing metrics based on the Google search activity of the user.
//
// The implementation schedules repeating tasks to compute the metrics when
// needed (at most once every day). The metrics are computed in the background
// and their computation is delayed at least a couple of seconds after the
// emitter is created to ensure browser startup performance is not affected.
//
// See http://goto.google.com/chrome-no-searchdomaincheck for more details on
// what domain mixing metrics are and how they are computed.
class GoogleSearchDomainMixingMetricsEmitter : public KeyedService {
public:
// Preference field holding the last time at which domain mixing metrics for
// Google searches were computed, as a base::Time object. See
// http://goto.google.com/chrome-no-searchdomaincheck for more details on what
// domain mixing metrics are and how they are computed.
static const char kLastMetricsTime[];
GoogleSearchDomainMixingMetricsEmitter(
PrefService* prefs,
history::HistoryService* history_service);
~GoogleSearchDomainMixingMetricsEmitter() override;
// Registers the preference fields used for computing Google search domain
// mixing metrics.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Starts the emitter. The implementation will schedule a background task to
// run the next time domain mixing metrics will need to be computed, and at
// least a few seconds after Start() is called if metrics need to be computed
// now. This delay is meant to ensure that browser startup performance is not
// affected.
void Start();
// Overrides the default clock for testing purposes.
void SetClockForTesting(std::unique_ptr<base::Clock> clock);
// Overrides the default timer for testing purposes.
void SetTimerForTesting(std::unique_ptr<base::Timer> timer);
// Overrides the UI thread task runner for testing purposes.
void SetUIThreadTaskRunnerForTesting(
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
private:
// Emits metrics for active days since the last one for which metrics were
// computed.
void EmitMetrics();
// KeyedService:
void Shutdown() override;
PrefService* const prefs_; // Not owned.
history::HistoryService* const history_service_; // Not owned.
std::unique_ptr<base::Clock> clock_ = std::make_unique<base::DefaultClock>();
// Timer used to compute domain mixing metrics daily if the emitter is
// long-lived.
std::unique_ptr<base::Timer> timer_ =
std::make_unique<base::RepeatingTimer>();
base::CancelableTaskTracker task_tracker_;
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_;
};
#endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter_factory.h"
#include <memory>
#include "base/memory/singleton.h"
#include "chrome/browser/history/history_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
const base::Feature GoogleSearchDomainMixingMetricsEmitterFactory::kFeature{
"EmitGoogleSearchDomainMixingMetrics", base::FEATURE_DISABLED_BY_DEFAULT};
// static
GoogleSearchDomainMixingMetricsEmitterFactory*
GoogleSearchDomainMixingMetricsEmitterFactory::GetInstance() {
return base::Singleton<GoogleSearchDomainMixingMetricsEmitterFactory>::get();
}
// static
GoogleSearchDomainMixingMetricsEmitter*
GoogleSearchDomainMixingMetricsEmitterFactory::GetForProfile(Profile* profile) {
return static_cast<GoogleSearchDomainMixingMetricsEmitter*>(
GetInstance()->GetServiceForBrowserContext(profile, /*create=*/true));
}
GoogleSearchDomainMixingMetricsEmitterFactory::
GoogleSearchDomainMixingMetricsEmitterFactory()
: BrowserContextKeyedServiceFactory(
"GoogleSearchDomainMixingMetricsEmitter",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(HistoryServiceFactory::GetInstance());
}
void GoogleSearchDomainMixingMetricsEmitterFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
GoogleSearchDomainMixingMetricsEmitter::RegisterProfilePrefs(registry);
}
KeyedService*
GoogleSearchDomainMixingMetricsEmitterFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
auto emitter = std::make_unique<GoogleSearchDomainMixingMetricsEmitter>(
profile->GetPrefs(), HistoryServiceFactory::GetInstance()->GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS));
emitter->Start();
return emitter.release();
}
bool GoogleSearchDomainMixingMetricsEmitterFactory::
ServiceIsCreatedWithBrowserContext() const {
return base::FeatureList::IsEnabled(kFeature);
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_FACTORY_H_
#define CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_FACTORY_H_
#include "base/feature_list.h"
#include "base/memory/singleton.h"
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
// Singleton that owns all GoogleSearchDomainMixingMetricsEmitters and
// associates them with Profiles.
class GoogleSearchDomainMixingMetricsEmitterFactory
: public BrowserContextKeyedServiceFactory {
public:
// Flag to enable computing domain mixing metrics based on the Google search
// activity of the user.
// For more details, see http://goto.google.com/chrome-no-searchdomaincheck.
static const base::Feature kFeature;
// Returns the singleton instance of the factory.
static GoogleSearchDomainMixingMetricsEmitterFactory* GetInstance();
// Returns the GoogleSearchDomainMixingMetricsEmitter for |profile|, creating
// one if needed. May return nullptr if there is no emitter should be created
// for the profile, e.g. in incognito mode.
static GoogleSearchDomainMixingMetricsEmitter* GetForProfile(
Profile* profile);
private:
friend struct base::DefaultSingletonTraits<
GoogleSearchDomainMixingMetricsEmitterFactory>;
friend class GoogleSearchDomainMixingMetricsEmitterFactoryTest;
GoogleSearchDomainMixingMetricsEmitterFactory();
// BrowserContextKeyedServiceFactory:
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
};
#endif // CHROME_BROWSER_GOOGLE_GOOGLE_SEARCH_DOMAIN_MIXING_METRICS_EMITTER_FACTORY_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter_factory.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
class GoogleSearchDomainMixingMetricsEmitterFactoryTest : public testing::Test {
protected:
bool ServiceIsCreatedWithBrowserContext() {
return GoogleSearchDomainMixingMetricsEmitterFactory::GetInstance()
->ServiceIsCreatedWithBrowserContext();
}
};
TEST_F(GoogleSearchDomainMixingMetricsEmitterFactoryTest, DisabledByDefault) {
EXPECT_FALSE(ServiceIsCreatedWithBrowserContext());
}
TEST_F(GoogleSearchDomainMixingMetricsEmitterFactoryTest, Enabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
GoogleSearchDomainMixingMetricsEmitterFactory::kFeature);
EXPECT_TRUE(ServiceIsCreatedWithBrowserContext());
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter.h"
#include "base/files/scoped_temp_dir.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/simple_test_clock.h"
#include "base/timer/mock_timer.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
class GoogleSearchDomainMixingMetricsEmitterTest : public testing::Test {
public:
GoogleSearchDomainMixingMetricsEmitterTest()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME) {}
void SetUp() override {
GoogleSearchDomainMixingMetricsEmitter::RegisterProfilePrefs(
prefs_.registry());
CHECK(history_dir_.CreateUniqueTempDir());
history_service_ = history::CreateHistoryService(history_dir_.GetPath(),
/*create_db=*/true);
emitter_ = std::make_unique<GoogleSearchDomainMixingMetricsEmitter>(
&prefs_, history_service_.get());
auto clock = std::make_unique<base::SimpleTestClock>();
clock_ = clock.get();
emitter_->SetClockForTesting(std::move(clock));
auto timer = std::make_unique<base::MockTimer>(/*retain_user_task=*/true,
/*is_repeating=*/true);
timer_ = timer.get();
emitter_->SetTimerForTesting(std::move(timer));
emitter_->SetUIThreadTaskRunnerForTesting(
scoped_task_environment_.GetMainThreadTaskRunner());
}
// Sets up test history such that domain mixing metrics for the day starting
// at last_metrics_time are what is verified by VerifyHistograms().
void SetUpTestHistory(base::Time last_metrics_time) {
// Out of range for the 30 day domain mixing metric.
history_service_->AddPage(GURL("https://www.google.de/search?q=foo"),
last_metrics_time - base::TimeDelta::FromDays(30),
history::SOURCE_BROWSED);
// First event in range for the 30 day domain mixing metric.
history_service_->AddPage(GURL("https://www.google.fr/search?q=foo"),
last_metrics_time - base::TimeDelta::FromDays(29),
history::SOURCE_BROWSED);
history_service_->AddPage(GURL("https://www.google.com/search?q=foo"),
last_metrics_time, history::SOURCE_BROWSED);
history_service_->AddPage(
GURL("https://www.google.com/search?q=foo"),
last_metrics_time + base::TimeDelta::FromHours(23),
history::SOURCE_BROWSED);
// Out of range for the day of metrics to compute.
history_service_->AddPage(
GURL("https://www.google.ch/search?q=foo"),
last_metrics_time + base::TimeDelta::FromHours(24),
history::SOURCE_BROWSED);
}
void VerifyHistograms(const base::HistogramTester& tester) {
tester.ExpectUniqueSample("DomainMixing.OneDay", 0, 1);
tester.ExpectUniqueSample("DomainMixing.OneWeek", 0, 1);
tester.ExpectUniqueSample("DomainMixing.TwoWeeks", 0, 1);
tester.ExpectUniqueSample("DomainMixing.OneMonth", 33, 1);
}
protected:
base::test::ScopedTaskEnvironment scoped_task_environment_;
TestingPrefServiceSimple prefs_;
base::ScopedTempDir history_dir_;
std::unique_ptr<history::HistoryService> history_service_;
std::unique_ptr<GoogleSearchDomainMixingMetricsEmitter> emitter_;
base::SimpleTestClock* clock_; // Not owned.
base::MockTimer* timer_; // Not owned.
};
TEST_F(GoogleSearchDomainMixingMetricsEmitterTest, FirstStart) {
base::Time now;
ASSERT_TRUE(base::Time::FromString("01 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
// The last metrics time should be initialized to 4am on the same day, so that
// metrics are from now on computed for daily windows anchored at 4am.
base::Time expected_last_metrics_time;
ASSERT_TRUE(base::Time::FromString("01 Jan 2018 04:00:00",
&expected_last_metrics_time));
emitter_->Start();
EXPECT_EQ(
expected_last_metrics_time,
prefs_.GetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime));
// The next metric calculation should be scheduled at 4am on the next day,
// i.e. 16 hours from |now|.
EXPECT_EQ(base::TimeDelta::FromHours(16),
scoped_task_environment_.NextMainThreadPendingTaskDelay());
}
TEST_F(GoogleSearchDomainMixingMetricsEmitterTest, Waits10SecondsAfterStart) {
base::Time now;
ASSERT_TRUE(base::Time::FromString("01 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
// Metrics were last computed a day ago and need to be recomputed immediately.
prefs_.SetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime,
now - base::TimeDelta::FromDays(1));
emitter_->Start();
EXPECT_EQ(base::TimeDelta::FromSeconds(10),
scoped_task_environment_.NextMainThreadPendingTaskDelay());
}
TEST_F(GoogleSearchDomainMixingMetricsEmitterTest, WaitsUntilNeeded) {
base::Time now;
ASSERT_TRUE(base::Time::FromString("01 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
// Metrics were last computed an hour ago and the emitter should wait 23 hours
// before emitting new metrics.
prefs_.SetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime,
now - base::TimeDelta::FromHours(1));
emitter_->Start();
EXPECT_EQ(base::TimeDelta::FromHours(23),
scoped_task_environment_.NextMainThreadPendingTaskDelay());
}
TEST_F(GoogleSearchDomainMixingMetricsEmitterTest, EmitsMetricsOnStart) {
// Metrics were computed up to 4am on Jan 1st.
base::Time last_metrics_time;
ASSERT_TRUE(
base::Time::FromString("01 Jan 2018 04:00:00", &last_metrics_time));
prefs_.SetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime,
last_metrics_time);
// It is now 12pm on Jan 2nd, so metrics for Jan 1st 4am to Jan 2nd 4am should
// be computed.
base::Time now;
ASSERT_TRUE(base::Time::FromString("02 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
SetUpTestHistory(last_metrics_time);
emitter_->Start();
base::HistogramTester tester;
scoped_task_environment_.FastForwardUntilNoTasksRemain();
BlockUntilHistoryProcessesPendingRequests(history_service_.get());
VerifyHistograms(tester);
}
TEST_F(GoogleSearchDomainMixingMetricsEmitterTest, EmitsMetricsWhenTimerFires) {
// Metrics were computed up to 4am on Jan 1st.
base::Time last_metrics_time;
ASSERT_TRUE(
base::Time::FromString("01 Jan 2018 04:00:00", &last_metrics_time));
prefs_.SetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime,
last_metrics_time);
// It is now 12pm on Jan 2nd, so metrics for Jan 1st 4am to Jan 2nd 4am should
// be computed.
base::Time now;
ASSERT_TRUE(base::Time::FromString("02 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
// Start the emitter.
emitter_->Start();
// Wait for the first run to be done.
scoped_task_environment_.FastForwardUntilNoTasksRemain();
BlockUntilHistoryProcessesPendingRequests(history_service_.get());
// last_metrics_time is expected to have been incremented.
last_metrics_time += base::TimeDelta::FromDays(1);
EXPECT_EQ(
last_metrics_time,
prefs_.GetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime));
// The timer is expected to trigger a day later.
EXPECT_EQ(base::TimeDelta::FromDays(1), timer_->GetCurrentDelay());
// A day later, metrics should be recomputed without a call to Start() when
// the timer triggers.
ASSERT_TRUE(base::Time::FromString("03 Jan 2018 12:00:00", &now));
clock_->SetNow(now);
SetUpTestHistory(last_metrics_time);
timer_->Fire();
base::HistogramTester tester;
scoped_task_environment_.FastForwardUntilNoTasksRemain();
BlockUntilHistoryProcessesPendingRequests(history_service_.get());
VerifyHistograms(tester);
// last_metrics_time is expected to have been incremented.
last_metrics_time += base::TimeDelta::FromDays(1);
EXPECT_EQ(
last_metrics_time,
prefs_.GetTime(GoogleSearchDomainMixingMetricsEmitter::kLastMetricsTime));
}
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/browser/engagement/site_engagement_service_factory.h"
#include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/feature_engagement/tracker_factory.h" #include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/google/google_search_domain_mixing_metrics_emitter_factory.h"
#include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
...@@ -264,6 +265,7 @@ void ChromeBrowserMainExtraPartsProfiles:: ...@@ -264,6 +265,7 @@ void ChromeBrowserMainExtraPartsProfiles::
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
GlobalErrorServiceFactory::GetInstance(); GlobalErrorServiceFactory::GetInstance();
#endif #endif
GoogleSearchDomainMixingMetricsEmitterFactory::GetInstance();
GoogleURLTrackerFactory::GetInstance(); GoogleURLTrackerFactory::GetInstance();
HistoryServiceFactory::GetInstance(); HistoryServiceFactory::GetInstance();
HostContentSettingsMapFactory::GetInstance(); HostContentSettingsMapFactory::GetInstance();
......
...@@ -2371,6 +2371,8 @@ test("unit_tests") { ...@@ -2371,6 +2371,8 @@ test("unit_tests") {
"../browser/font_pref_change_notifier_unittest.cc", "../browser/font_pref_change_notifier_unittest.cc",
"../browser/geolocation/geolocation_permission_context_unittest.cc", "../browser/geolocation/geolocation_permission_context_unittest.cc",
"../browser/global_keyboard_shortcuts_mac_unittest.mm", "../browser/global_keyboard_shortcuts_mac_unittest.mm",
"../browser/google/google_search_domain_mixing_metrics_emitter_factory_unittest.cc",
"../browser/google/google_search_domain_mixing_metrics_emitter_unittest.cc",
"../browser/google/google_update_settings_unittest.cc", "../browser/google/google_update_settings_unittest.cc",
"../browser/google/google_url_tracker_factory_unittest.cc", "../browser/google/google_url_tracker_factory_unittest.cc",
"../browser/history/android/android_cache_database_unittest.cc", "../browser/history/android/android_cache_database_unittest.cc",
......
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