Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (272531 => 272532)
--- branches/safari-611-branch/Source/WebKit/ChangeLog 2021-02-08 21:03:39 UTC (rev 272531)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog 2021-02-08 21:03:43 UTC (rev 272532)
@@ -1,5 +1,94 @@
2021-02-08 Russell Epstein <[email protected]>
+ Cherry-pick r272346. rdar://problem/74105218
+
+ PCM: earliestTimeToSend should be treated as an independent time value, not relative to timeOfAdClick
+ https://bugs.webkit.org/show_bug.cgi?id=221303
+ <rdar://problem/73902668>
+
+ Reviewed by John Wilander.
+
+ r270136 assumed that PCM's earliestTimeToSend attribute was the
+ difference between timeOfAdClick and when the attribution should be
+ sent. As a result, it began each new browser session by adjusting
+ this value based on the amount of time the session was closed.
+ In reality, earliestTimeToSend is a raw secondsSinceEpoch() value, so we don't
+ need any adjustment after a new session.
+
+ No new tests, this is covered by
+ http/tests/privateClickMeasurement/expired-attribution-report-gets-sent-on-session-start.html
+ now that the corresponding test SPI has been updated.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ (WebKit::createTableQueries):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::destroyStatements):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
+ Update the testing SPI to insert an expired time of now minus one
+ hour as the earliestTimeToSend.
+
+ (WebKit::ResourceLoadStatisticsDatabaseStore::updateTimerLastFired): Deleted.
+ (WebKit::ResourceLoadStatisticsDatabaseStore::timerLastFired): Deleted.
+ (WebKit::ResourceLoadStatisticsDatabaseStore::updatePrivateClickMeasurementAttributionTimes): Deleted.
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::updateTimerLastFired): Deleted.
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/PrivateClickMeasurementManager.cpp:
+ (WebKit::PrivateClickMeasurementManager::firePendingAttributionRequests):
+ (WebKit::PrivateClickMeasurementManager::updateTimerLastFired): Deleted.
+ * NetworkProcess/PrivateClickMeasurementManager.h:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-03 Kate Cheney <[email protected]>
+
+ PCM: earliestTimeToSend should be treated as an independent time value, not relative to timeOfAdClick
+ https://bugs.webkit.org/show_bug.cgi?id=221303
+ <rdar://problem/73902668>
+
+ Reviewed by John Wilander.
+
+ r270136 assumed that PCM's earliestTimeToSend attribute was the
+ difference between timeOfAdClick and when the attribution should be
+ sent. As a result, it began each new browser session by adjusting
+ this value based on the amount of time the session was closed.
+ In reality, earliestTimeToSend is a raw secondsSinceEpoch() value, so we don't
+ need any adjustment after a new session.
+
+ No new tests, this is covered by
+ http/tests/privateClickMeasurement/expired-attribution-report-gets-sent-on-session-start.html
+ now that the corresponding test SPI has been updated.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ (WebKit::createTableQueries):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::destroyStatements):
+ (WebKit::ResourceLoadStatisticsDatabaseStore::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
+ Update the testing SPI to insert an expired time of now minus one
+ hour as the earliestTimeToSend.
+
+ (WebKit::ResourceLoadStatisticsDatabaseStore::updateTimerLastFired): Deleted.
+ (WebKit::ResourceLoadStatisticsDatabaseStore::timerLastFired): Deleted.
+ (WebKit::ResourceLoadStatisticsDatabaseStore::updatePrivateClickMeasurementAttributionTimes): Deleted.
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+ * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::updateTimerLastFired): Deleted.
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/PrivateClickMeasurementManager.cpp:
+ (WebKit::PrivateClickMeasurementManager::firePendingAttributionRequests):
+ (WebKit::PrivateClickMeasurementManager::updateTimerLastFired): Deleted.
+ * NetworkProcess/PrivateClickMeasurementManager.h:
+
+2021-02-08 Russell Epstein <[email protected]>
+
Cherry-pick r272335. rdar://problem/74032694
REGRESSION (r270392): Launch time regression under IOSurface::maximumSize()
Modified: branches/safari-611-branch/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (272531 => 272532)
--- branches/safari-611-branch/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-02-08 21:03:39 UTC (rev 272531)
+++ branches/safari-611-branch/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-02-08 21:03:43 UTC (rev 272532)
@@ -85,7 +85,6 @@
"sourceID, timeOfAdClick) VALUES (?, ?, ?, ?)"_s;
constexpr auto insertAttributedPrivateClickMeasurementQuery = "INSERT OR REPLACE INTO AttributedPrivateClickMeasurement (sourceSiteDomainID, attributeOnSiteDomainID, "
"sourceID, attributionTriggerData, priority, timeOfAdClick, earliestTimeToSend) VALUES (?, ?, ?, ?, ?, ?, ?)"_s;
-constexpr auto updateTimerLastFiredQuery = "INSERT OR REPLACE INTO TimerLastFired (key, timeLastFiredSeconds) VALUES (1, ?)"_s;
// INSERT OR REPLACE Queries
constexpr auto subframeUnderTopFrameDomainsQuery = "INSERT OR REPLACE into SubframeUnderTopFrameDomains (subFrameDomainID, lastUpdated, topFrameDomainID) SELECT ?, ?, domainID FROM ObservedDomains where registrableDomain in ( "_s;
@@ -143,7 +142,6 @@
constexpr auto allAttributedPrivateClickMeasurementQuery = "SELECT * FROM AttributedPrivateClickMeasurement"_s;
constexpr auto findUnattributedQuery = "SELECT * FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND attributeOnSiteDomainID = ?"_s;
constexpr auto findAttributedQuery = "SELECT * FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND attributeOnSiteDomainID = ?"_s;
-constexpr auto timerLastFiredQuery = "SELECT timeLastFiredSeconds FROM TimerLastFired WHERE key = 1"_s;
// EXISTS for testing queries
constexpr auto linkDecorationExistsQuery = "SELECT EXISTS (SELECT * FROM TopFrameLinkDecorationsFrom WHERE toDomainID = ? OR fromDomainID = ?)"_s;
@@ -250,9 +248,6 @@
"FOREIGN KEY(sourceSiteDomainID) REFERENCES ObservedDomains(domainID) ON DELETE CASCADE, "
"FOREIGN KEY(attributeOnSiteDomainID) REFERENCES ObservedDomains(domainID) ON DELETE CASCADE);"_s;
-constexpr auto createTimerLastFired = "CREATE TABLE TimerLastFired ( key INTEGER PRIMARY KEY, "
- " timeLastFiredSeconds REAL NOT NULL )"_s;
-
// CREATE UNIQUE INDEX Queries.
constexpr auto createUniqueIndexStorageAccessUnderTopFrameDomains = "CREATE UNIQUE INDEX IF NOT EXISTS StorageAccessUnderTopFrameDomains_domainID_topLevelDomainID on StorageAccessUnderTopFrameDomains ( domainID, topLevelDomainID );"_s;
constexpr auto createUniqueIndexTopFrameUniqueRedirectsTo = "CREATE UNIQUE INDEX IF NOT EXISTS TopFrameUniqueRedirectsTo_sourceDomainID_toDomainID on TopFrameUniqueRedirectsTo ( sourceDomainID, toDomainID );"_s;
@@ -300,8 +295,7 @@
{ "SubresourceUniqueRedirectsFrom"_s, createSubresourceUniqueRedirectsFrom},
{ "OperatingDates"_s, createOperatingDates},
{ "UnattributedPrivateClickMeasurement"_s, createUnattributedPrivateClickMeasurement},
- { "AttributedPrivateClickMeasurement"_s, createAttributedPrivateClickMeasurement},
- { "TimerLastFired"_s, createTimerLastFired}
+ { "AttributedPrivateClickMeasurement"_s, createAttributedPrivateClickMeasurement}
});
return createTableQueries;
@@ -332,7 +326,6 @@
RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::turnOnIncrementalAutoVacuum failed, error message: %" PUBLIC_LOG_STRING, this, m_database.lastErrorMsg());
includeTodayAsOperatingDateIfNecessary();
- updatePrivateClickMeasurementAttributionTimes();
allStores().add(this);
}
@@ -681,11 +674,6 @@
LOG_ERROR("Could not create AttributedPrivateClickMeasurement table in database (%i) - %s", m_database.lastError(), m_database.lastErrorMsg());
return false;
}
-
- if (!m_database.executeCommand(createTimerLastFired)) {
- LOG_ERROR("Could not create TimerLastFired table in database (%i) - %s", m_database.lastError(), m_database.lastErrorMsg());
- return false;
- }
if (!createUniqueIndices())
return false;
@@ -744,8 +732,6 @@
m_allAttributedPrivateClickMeasurementStatement = nullptr;
m_findUnattributedStatement = nullptr;
m_findAttributedStatement = nullptr;
- m_updateTimerLastFiredStatement = nullptr;
- m_timerLastFiredStatement = nullptr;
m_updateAttributionsEarliestTimeToSendStatement = nullptr;
m_removeUnattributedStatement = nullptr;
}
@@ -2890,54 +2876,6 @@
}
}
-void ResourceLoadStatisticsDatabaseStore::updateTimerLastFired()
-{
- auto scopedStatement = this->scopedStatement(m_updateTimerLastFiredStatement, updateTimerLastFiredQuery, "updateTimerLastFired"_s);
-
- auto now = WallTime::now().secondsSinceEpoch().value();
-
- if (!scopedStatement
- || scopedStatement->bindDouble(1, now) != SQLITE_OK
- || scopedStatement->step() != SQLITE_DONE) {
- RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::updateTimerLastFired failed, error message: %{private}s", this, m_database.lastErrorMsg());
- ASSERT_NOT_REACHED();
- }
-}
-
-WallTime ResourceLoadStatisticsDatabaseStore::timerLastFired()
-{
- auto scopedStatement = this->scopedStatement(m_timerLastFiredStatement, timerLastFiredQuery, "timerLastFired"_s);
-
- if (!scopedStatement) {
- RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::timerLastFired, error message: %{private}s", this, m_database.lastErrorMsg());
- ASSERT_NOT_REACHED();
- }
-
- if (scopedStatement->step() == SQLITE_ROW)
- return WallTime::fromRawSeconds(scopedStatement->getColumnDouble(0));
-
- return WallTime::now();
-}
-
-void ResourceLoadStatisticsDatabaseStore::updatePrivateClickMeasurementAttributionTimes()
-{
- // We should update attributions on session-start to account for the time
- // that passed while the session was closed. If the amount of time since the last
- // timer fire is greater than the earliestTimeToSend, we should set earliestTimeToSend
- // to be immediately.
- auto lastFired = timerLastFired();
- auto timePassed = WallTime::now() - lastFired;
-
- auto scopedStatement = this->scopedStatement(m_updateAttributionsEarliestTimeToSendStatement, updateAttributionsEarliestTimeToSendQuery, "updatePrivateClickMeasurementAttributionTimes"_s);
-
- if (!scopedStatement
- || scopedStatement->bindDouble(1, timePassed.value()) != SQLITE_OK
- || scopedStatement->step() != SQLITE_DONE) {
- RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::updatePrivateClickMeasurementAttributionTimes, error message: %{private}s", this, m_database.lastErrorMsg());
- ASSERT_NOT_REACHED();
- }
-}
-
PrivateClickMeasurement ResourceLoadStatisticsDatabaseStore::buildPrivateClickMeasurementFromDatabase(WebCore::SQLiteStatement* statement, PrivateClickMeasurementAttributionType attributionType)
{
auto sourceSiteDomain = getDomainStringFromDomainID(statement->getColumnInt(0));
@@ -3315,21 +3253,11 @@
void ResourceLoadStatisticsDatabaseStore::markAttributedPrivateClickMeasurementsAsExpiredForTesting()
{
- // Update the last timer fired time to be one day ago.
- auto yesterday = (WallTime::now() - 24_h).secondsSinceEpoch().value();
- auto scopedStatement = this->scopedStatement(m_updateTimerLastFiredStatement, updateTimerLastFiredQuery, "insertExpiredAttributionTesting"_s);
- if (!scopedStatement
- || scopedStatement->bindDouble(1, yesterday) != SQLITE_OK
- || scopedStatement->step() != SQLITE_DONE) {
- RELEASE_LOG_ERROR(Network, "%p - ResourceLoadStatisticsDatabaseStore::insertExpiredAttributionTesting failed, error message: %{private}s", this, m_database.lastErrorMsg());
- ASSERT_NOT_REACHED();
- }
-
- auto expiredTimeToSend = 1_h; // Must be less than 1 day.
+ auto expiredTimeToSend = WallTime::now() - 1_h;
auto statement = SQLiteStatement(m_database, "UPDATE AttributedPrivateClickMeasurement SET earliestTimeToSend = ?");
if (statement.prepare() != SQLITE_OK
- || statement.bindInt(1, expiredTimeToSend.value()) != SQLITE_OK
+ || statement.bindInt(1, expiredTimeToSend.secondsSinceEpoch().value()) != SQLITE_OK
|| statement.step() != SQLITE_DONE) {
RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::insertPrivateClickMeasurement, error message: %{private}s", this, m_database.lastErrorMsg());
ASSERT_NOT_REACHED();