summaryrefslogtreecommitdiff
path: root/chromium/components/ukm
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-20 13:40:20 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-22 12:41:23 +0000
commit7961cea6d1041e3e454dae6a1da660b453efd238 (patch)
treec0eeb4a9ff9ba32986289c1653d9608e53ccb444 /chromium/components/ukm
parentb7034d0803538058e5c9d904ef03cf5eab34f6ef (diff)
downloadqtwebengine-chromium-7961cea6d1041e3e454dae6a1da660b453efd238.tar.gz
BASELINE: Update Chromium to 78.0.3904.130
Change-Id: If185e0c0061b3437531c97c9c8c78f239352a68b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/ukm')
-rw-r--r--chromium/components/ukm/app_source_url_recorder_test.cc4
-rw-r--r--chromium/components/ukm/content/source_url_recorder_browsertest.cc9
-rw-r--r--chromium/components/ukm/debug/ukm_internals.js2
-rw-r--r--chromium/components/ukm/ukm_recorder_impl.cc17
-rw-r--r--chromium/components/ukm/ukm_service.cc12
-rw-r--r--chromium/components/ukm/ukm_service.h14
-rw-r--r--chromium/components/ukm/ukm_service_unittest.cc18
7 files changed, 42 insertions, 34 deletions
diff --git a/chromium/components/ukm/app_source_url_recorder_test.cc b/chromium/components/ukm/app_source_url_recorder_test.cc
index 444dedd4119..4015d76d2e2 100644
--- a/chromium/components/ukm/app_source_url_recorder_test.cc
+++ b/chromium/components/ukm/app_source_url_recorder_test.cc
@@ -5,7 +5,7 @@
#include "components/ukm/app_source_url_recorder.h"
#include "base/test/scoped_feature_list.h"
-#include "base/test/scoped_task_environment.h"
+#include "base/test/task_environment.h"
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,7 +29,7 @@ class AppSourceUrlRecorderTest : public testing::Test {
}
base::test::ScopedFeatureList scoped_feature_list_;
- base::test::ScopedTaskEnvironment scoped_task_environment_;
+ base::test::TaskEnvironment task_environment_;
TestAutoSetUkmRecorder test_ukm_recorder_;
};
diff --git a/chromium/components/ukm/content/source_url_recorder_browsertest.cc b/chromium/components/ukm/content/source_url_recorder_browsertest.cc
index ff755a6783f..72969135457 100644
--- a/chromium/components/ukm/content/source_url_recorder_browsertest.cc
+++ b/chromium/components/ukm/content/source_url_recorder_browsertest.cc
@@ -94,7 +94,7 @@ IN_PROC_BROWSER_TEST_F(SourceUrlRecorderWebContentsObserverBrowserTest,
GURL url = embedded_test_server()->GetURL("/title1.html");
content::NavigationHandleObserver observer(shell()->web_contents(), url);
- content::NavigateToURL(shell(), url);
+ EXPECT_TRUE(content::NavigateToURL(shell(), url));
EXPECT_TRUE(observer.has_committed());
const ukm::UkmSource* source =
GetSourceForNavigationId(observer.navigation_id());
@@ -130,7 +130,7 @@ IN_PROC_BROWSER_TEST_F(SourceUrlRecorderWebContentsObserverBrowserTest,
main_url);
content::NavigationHandleObserver subframe_observer(shell()->web_contents(),
subframe_url);
- content::NavigateToURL(shell(), main_url);
+ EXPECT_TRUE(content::NavigateToURL(shell(), main_url));
EXPECT_TRUE(main_observer.has_committed());
EXPECT_TRUE(main_observer.is_main_frame());
EXPECT_TRUE(subframe_observer.has_committed());
@@ -161,12 +161,11 @@ IN_PROC_BROWSER_TEST_F(SourceUrlRecorderWebContentsObserverBrowserTest,
EXPECT_NE(source->id(), ukm_entries[1]->source_id);
}
-// Flaky on all OSes: https://crbug.com/951020
IN_PROC_BROWSER_TEST_F(SourceUrlRecorderWebContentsObserverDownloadBrowserTest,
- DISABLED_IgnoreDownload) {
+ IgnoreDownload) {
GURL url(embedded_test_server()->GetURL("/download-test1.lib"));
content::NavigationHandleObserver observer(shell()->web_contents(), url);
- content::NavigateToURL(shell(), url);
+ EXPECT_TRUE(content::NavigateToURLAndExpectNoCommit(shell(), url));
EXPECT_FALSE(observer.has_committed());
EXPECT_TRUE(observer.is_download());
EXPECT_EQ(nullptr, GetSourceForNavigationId(observer.navigation_id()));
diff --git a/chromium/components/ukm/debug/ukm_internals.js b/chromium/components/ukm/debug/ukm_internals.js
index 5bec3e1aafc..92aebee3912 100644
--- a/chromium/components/ukm/debug/ukm_internals.js
+++ b/chromium/components/ukm/debug/ukm_internals.js
@@ -86,7 +86,7 @@ function as64Bit(num) {
/**
* Sets the display option of all the elements in HtmlCollection to the value
* passed.
- * @param {!NodeList<!Element>} collection Collection of Elements.
+ * @param {!HTMLCollection<!Element>} collection Collection of Elements.
*/
function setDisplayStyle(collection, display_value) {
for (const el of collection) {
diff --git a/chromium/components/ukm/ukm_recorder_impl.cc b/chromium/components/ukm/ukm_recorder_impl.cc
index 4e265f9b44d..55f90237c52 100644
--- a/chromium/components/ukm/ukm_recorder_impl.cc
+++ b/chromium/components/ukm/ukm_recorder_impl.cc
@@ -64,8 +64,9 @@ size_t GetMaxSources() {
kUkmFeature, "MaxSources", kDefaultMaxSources));
}
-// Gets the maximum number of Sources we can kept in memory to defer to the next
-// reporting interval at the end of the current reporting cycle.
+// Gets the maximum number of Sources we can keep in memory at the end of the
+// current reporting cycle that will stay accessible in the next reporting
+// interval.
size_t GetMaxKeptSources() {
constexpr size_t kDefaultMaxKeptSources = 100;
return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
@@ -295,9 +296,11 @@ void UkmRecorderImpl::StoreRecordingsInReport(Report* report) {
std::unordered_map<ukm::SourceIdType, int> serialized_source_type_counts;
for (const auto& kv : recordings_.sources) {
- // Sources of non-navigation types will not be kept after current report.
- if (GetSourceIdType(kv.first) != base::UkmSourceId::Type::NAVIGATION_ID) {
- recordings_.obsolete_source_ids.insert(kv.first);
+ // Don't keep sources of these types after current report because their
+ // entries are logged only at source creation time.
+ if (GetSourceIdType(kv.first) == base::UkmSourceId::Type::APP_ID ||
+ GetSourceIdType(kv.first) == base::UkmSourceId::Type::HISTORY_ID) {
+ MarkSourceForDeletion(kv.first);
}
// If the source id is not whitelisted, don't send it unless it has
// associated entries and the URL matches that of a whitelisted source.
@@ -316,6 +319,10 @@ void UkmRecorderImpl::StoreRecordingsInReport(Report* report) {
// Omit entryless sources from the report.
if (!base::Contains(source_ids_seen, kv.first)) {
continue;
+ } else {
+ // Source of base::UkmSourceId::Type::UKM type will not be kept after
+ // entries are logged.
+ MarkSourceForDeletion(kv.first);
}
}
Source* proto_source = report->add_sources();
diff --git a/chromium/components/ukm/ukm_service.cc b/chromium/components/ukm/ukm_service.cc
index 66025adce8a..581cbf7f89c 100644
--- a/chromium/components/ukm/ukm_service.cc
+++ b/chromium/components/ukm/ukm_service.cc
@@ -78,13 +78,8 @@ UkmService::UkmService(PrefService* pref_service,
bool restrict_to_whitelist_entries)
: pref_service_(pref_service),
restrict_to_whitelist_entries_(restrict_to_whitelist_entries),
- client_id_(0),
- session_id_(0),
- report_count_(0),
client_(client),
- reporting_service_(client, pref_service),
- initialize_started_(false),
- initialize_complete_(false) {
+ reporting_service_(client, pref_service) {
DCHECK(pref_service_);
DCHECK(client_);
DVLOG(1) << "UkmService::Constructor";
@@ -131,6 +126,7 @@ void UkmService::EnableReporting() {
if (reporting_service_.reporting_active())
return;
+ log_creation_time_ = base::TimeTicks::Now();
metrics_providers_.OnRecordingEnabled();
if (!initialize_started_)
@@ -260,8 +256,8 @@ void UkmService::BuildAndStoreLog() {
metrics::MetricsLog::RecordCoreSystemProfile(client_,
report.mutable_system_profile());
- metrics_providers_.ProvideSystemProfileMetrics(
- report.mutable_system_profile());
+ metrics_providers_.ProvideSystemProfileMetricsWithLogCreationTime(
+ log_creation_time_, report.mutable_system_profile());
std::string serialized_log;
report.SerializeToString(&serialized_log);
diff --git a/chromium/components/ukm/ukm_service.h b/chromium/components/ukm/ukm_service.h
index 067aac66c2a..a510c2857e4 100644
--- a/chromium/components/ukm/ukm_service.h
+++ b/chromium/components/ukm/ukm_service.h
@@ -128,13 +128,13 @@ class UkmService : public UkmRecorderImpl {
bool restrict_to_whitelist_entries_;
// The UKM client id stored in prefs.
- uint64_t client_id_;
+ uint64_t client_id_ = 0;
// The UKM session id stored in prefs.
- int32_t session_id_;
+ int32_t session_id_ = 0;
// The number of reports generated this session.
- int32_t report_count_;
+ int32_t report_count_ = 0;
// Used to interact with the embedder. Weak pointer; must outlive |this|
// instance.
@@ -149,10 +149,12 @@ class UkmService : public UkmRecorderImpl {
// The scheduler for determining when uploads should happen.
std::unique_ptr<metrics::MetricsRotationScheduler> scheduler_;
- SEQUENCE_CHECKER(sequence_checker_);
+ base::TimeTicks log_creation_time_;
+
+ bool initialize_started_ = false;
+ bool initialize_complete_ = false;
- bool initialize_started_;
- bool initialize_complete_;
+ SEQUENCE_CHECKER(sequence_checker_);
// Weak pointers factory used to post task on different threads. All weak
// pointers managed by this factory have the same lifetime as UkmService.
diff --git a/chromium/components/ukm/ukm_service_unittest.cc b/chromium/components/ukm/ukm_service_unittest.cc
index 5a7dd66d0bf..c1e0f4b3233 100644
--- a/chromium/components/ukm/ukm_service_unittest.cc
+++ b/chromium/components/ukm/ukm_service_unittest.cc
@@ -711,8 +711,10 @@ TEST_F(UkmServiceTest, UnreferencedNonWhitelistedSources) {
// The one whitelisted source is of navigation type.
EXPECT_EQ(1, proto_report.source_counts().navigation_sources());
EXPECT_EQ(0, proto_report.source_counts().unmatched_sources());
- // Only the navigation type source is deferred.
- EXPECT_EQ(1, proto_report.source_counts().deferred_sources());
+ // Source 0 of navigation type, and entryless sources 1, 3, 4, 5 of
+ // non-whitelisted type are eligible to be deferred, but MaxKeptSources
+ // restricts deferral to the 3 latest created ones.
+ EXPECT_EQ(3, proto_report.source_counts().deferred_sources());
EXPECT_EQ(0, proto_report.source_counts().carryover_sources());
ASSERT_EQ(3, proto_report.sources_size());
@@ -756,12 +758,14 @@ TEST_F(UkmServiceTest, UnreferencedNonWhitelistedSources) {
// Only the navigation type source is deferred.
EXPECT_EQ(1, proto_report.source_counts().deferred_sources());
// Number of sources carried over from the previous report to this report.
- EXPECT_EQ(1, proto_report.source_counts().carryover_sources());
- // Only the navigation source is again included in current report and
- // there is a new entry associated to it.
- ASSERT_EQ(1, proto_report.sources_size());
- EXPECT_EQ(whitelisted_id, proto_report.sources(0).id());
+ EXPECT_EQ(3, proto_report.source_counts().carryover_sources());
+ // Out of sources 3, 4, 5 that were retained from the previous cycle,
+ // sources 3 and 4 got new entries are thus included in this report.
+ ASSERT_EQ(2, proto_report.sources_size());
+ EXPECT_EQ(ids[3], proto_report.sources(0).id());
EXPECT_EQ(kURL.spec(), proto_report.sources(0).url());
+ EXPECT_EQ(ids[4], proto_report.sources(1).id());
+ EXPECT_EQ(kURL.spec(), proto_report.sources(1).url());
}
}
}