Commit 77229989 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Fix a static initializer issue in LocalSiteCharImpl.

TimeDeltaToInternalRepresentation can't return a constexpr because it
uses TimeDelta::InSeconds which can't be evaluated at compile time,
remove the |kZeroIntervalInternalRepresentation| value as this doesn't
provide any clear value here.

Bug: 773382,846431
Change-Id: I6b2df260742c239cc664e8476c726d4ba15731dc
Reviewed-on: https://chromium-review.googlesource.com/1072347
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561608}
parent 40e9c223
...@@ -35,12 +35,6 @@ std::vector<SiteCharacteristicsFeatureProto*> GetAllFeaturesFromProto( ...@@ -35,12 +35,6 @@ std::vector<SiteCharacteristicsFeatureProto*> GetAllFeaturesFromProto(
} // namespace } // namespace
// static:
const int64_t
LocalSiteCharacteristicsDataImpl::kZeroIntervalInternalRepresentation =
LocalSiteCharacteristicsDataImpl::TimeDeltaToInternalRepresentation(
base::TimeDelta());
void LocalSiteCharacteristicsDataImpl::NotifySiteLoaded() { void LocalSiteCharacteristicsDataImpl::NotifySiteLoaded() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Update the last loaded time when this origin gets loaded for the first // Update the last loaded time when this origin gets loaded for the first
...@@ -203,8 +197,11 @@ void LocalSiteCharacteristicsDataImpl:: ...@@ -203,8 +197,11 @@ void LocalSiteCharacteristicsDataImpl::
InitSiteCharacteristicsFeatureProtoWithDefaultValues( InitSiteCharacteristicsFeatureProtoWithDefaultValues(
SiteCharacteristicsFeatureProto* proto) { SiteCharacteristicsFeatureProto* proto) {
DCHECK_NE(nullptr, proto); DCHECK_NE(nullptr, proto);
proto->set_observation_duration(kZeroIntervalInternalRepresentation); static const auto zero_interval =
proto->set_use_timestamp(kZeroIntervalInternalRepresentation); LocalSiteCharacteristicsDataImpl::TimeDeltaToInternalRepresentation(
base::TimeDelta());
proto->set_observation_duration(zero_interval);
proto->set_use_timestamp(zero_interval);
} }
void LocalSiteCharacteristicsDataImpl::InitWithDefaultValues( void LocalSiteCharacteristicsDataImpl::InitWithDefaultValues(
...@@ -219,7 +216,9 @@ void LocalSiteCharacteristicsDataImpl::InitWithDefaultValues( ...@@ -219,7 +216,9 @@ void LocalSiteCharacteristicsDataImpl::InitWithDefaultValues(
if (!only_init_uninitialized_fields || if (!only_init_uninitialized_fields ||
!site_characteristics_.has_last_loaded()) { !site_characteristics_.has_last_loaded()) {
site_characteristics_.set_last_loaded(kZeroIntervalInternalRepresentation); site_characteristics_.set_last_loaded(
LocalSiteCharacteristicsDataImpl::TimeDeltaToInternalRepresentation(
base::TimeDelta()));
} }
} }
...@@ -274,7 +273,9 @@ void LocalSiteCharacteristicsDataImpl::NotifyFeatureUsage( ...@@ -274,7 +273,9 @@ void LocalSiteCharacteristicsDataImpl::NotifyFeatureUsage(
feature_proto->set_use_timestamp( feature_proto->set_use_timestamp(
TimeDeltaToInternalRepresentation(GetTickDeltaSinceEpoch())); TimeDeltaToInternalRepresentation(GetTickDeltaSinceEpoch()));
feature_proto->set_observation_duration(kZeroIntervalInternalRepresentation); feature_proto->set_observation_duration(
LocalSiteCharacteristicsDataImpl::TimeDeltaToInternalRepresentation(
base::TimeDelta()));
} }
void LocalSiteCharacteristicsDataImpl::OnInitCallback( void LocalSiteCharacteristicsDataImpl::OnInitCallback(
...@@ -300,13 +301,17 @@ void LocalSiteCharacteristicsDataImpl::OnInitCallback( ...@@ -300,13 +301,17 @@ void LocalSiteCharacteristicsDataImpl::OnInitCallback(
(*this_features_iter) (*this_features_iter)
->set_use_timestamp((*db_features_iter)->use_timestamp()); ->set_use_timestamp((*db_features_iter)->use_timestamp());
(*this_features_iter) (*this_features_iter)
->set_observation_duration(kZeroIntervalInternalRepresentation); ->set_observation_duration(
LocalSiteCharacteristicsDataImpl::
TimeDeltaToInternalRepresentation(base::TimeDelta()));
} else { } else {
// Else, add the observation duration from the database to the // Else, add the observation duration from the database to the
// in-memory observation duration. // in-memory observation duration.
if (!(*this_features_iter)->has_observation_duration()) { if (!(*this_features_iter)->has_observation_duration()) {
(*this_features_iter) (*this_features_iter)
->set_observation_duration(kZeroIntervalInternalRepresentation); ->set_observation_duration(
LocalSiteCharacteristicsDataImpl::
TimeDeltaToInternalRepresentation(base::TimeDelta()));
} }
IncrementFeatureObservationDuration( IncrementFeatureObservationDuration(
(*this_features_iter), (*this_features_iter),
......
...@@ -121,8 +121,6 @@ class LocalSiteCharacteristicsDataImpl ...@@ -121,8 +121,6 @@ class LocalSiteCharacteristicsDataImpl
FRIEND_TEST_ALL_PREFIXES(LocalSiteCharacteristicsDataImplTest, FRIEND_TEST_ALL_PREFIXES(LocalSiteCharacteristicsDataImplTest,
LateAsyncReadDoesntBypassClearEvent); LateAsyncReadDoesntBypassClearEvent);
static const int64_t kZeroIntervalInternalRepresentation;
// Add |extra_observation_duration| to the observation window of a given // Add |extra_observation_duration| to the observation window of a given
// feature if it hasn't been used yet, do nothing otherwise. // feature if it hasn't been used yet, do nothing otherwise.
static void IncrementFeatureObservationDuration( static void IncrementFeatureObservationDuration(
......
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