Skip to content

Commit b66b7fa

Browse files
committed
Bug 1606207 - Remove first-party cache isolation telemetry r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D59352 --HG-- extra : moz-landing-system : lando
1 parent 86e7bf1 commit b66b7fa

17 files changed

+27
-470
lines changed

netwerk/cache2/CacheEntry.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,13 +1091,6 @@ nsresult CacheEntry::SetContentType(uint8_t aContentType) {
10911091
return NS_ERROR_NOT_AVAILABLE;
10921092
}
10931093

1094-
nsresult CacheEntry::AddBaseDomainAccess(uint32_t aSiteID) {
1095-
if (NS_SUCCEEDED(mFileStatus)) {
1096-
return mFile->AddBaseDomainAccess(aSiteID);
1097-
}
1098-
return NS_ERROR_NOT_AVAILABLE;
1099-
}
1100-
11011094
nsresult CacheEntry::GetIsForcedValid(bool* aIsForcedValid) {
11021095
NS_ENSURE_ARG(aIsForcedValid);
11031096

netwerk/cache2/CacheEntry.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener {
7373
nsresult GetOnStopTime(uint64_t* aOnStopTime);
7474
nsresult SetNetworkTimes(uint64_t onStartTime, uint64_t onStopTime);
7575
nsresult SetContentType(uint8_t aContentType);
76-
nsresult AddBaseDomainAccess(uint32_t aSiteID);
7776
nsresult ForceValidFor(uint32_t aSecondsToTheFuture);
7877
nsresult GetIsForcedValid(bool* aIsForcedValid);
7978
nsresult OpenInputStream(int64_t offset, nsIInputStream** _retval);
@@ -468,9 +467,6 @@ class CacheEntryHandle final : public nsICacheEntry {
468467
NS_IMETHOD SetContentType(uint8_t contentType) override {
469468
return mEntry->SetContentType(contentType);
470469
}
471-
NS_IMETHOD AddBaseDomainAccess(uint32_t aSiteID) override {
472-
return mEntry->AddBaseDomainAccess(aSiteID);
473-
}
474470
NS_IMETHOD ForceValidFor(uint32_t aSecondsToTheFuture) override {
475471
return mEntry->ForceValidFor(aSecondsToTheFuture);
476472
}

netwerk/cache2/CacheFile.cpp

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ nsresult CacheFile::SetFrecency(uint32_t aFrecency) {
11661166

11671167
if (mHandle && !mHandle->IsDoomed())
11681168
CacheFileIOManager::UpdateIndexEntry(mHandle, &aFrecency, nullptr, nullptr,
1169-
nullptr, nullptr, nullptr, 0);
1169+
nullptr, nullptr);
11701170

11711171
mMetadata->SetFrecency(aFrecency);
11721172
return NS_OK;
@@ -1216,8 +1216,7 @@ nsresult CacheFile::SetNetworkTimes(uint64_t aOnStartTime,
12161216

12171217
if (mHandle && !mHandle->IsDoomed()) {
12181218
CacheFileIOManager::UpdateIndexEntry(mHandle, nullptr, nullptr,
1219-
&onStartTime16, &onStopTime16, nullptr,
1220-
nullptr, 0);
1219+
&onStartTime16, &onStopTime16, nullptr);
12211220
}
12221221
return NS_OK;
12231222
}
@@ -1272,54 +1271,7 @@ nsresult CacheFile::SetContentType(uint8_t aContentType) {
12721271

12731272
if (mHandle && !mHandle->IsDoomed()) {
12741273
CacheFileIOManager::UpdateIndexEntry(mHandle, nullptr, nullptr, nullptr,
1275-
nullptr, &aContentType, nullptr, 0);
1276-
}
1277-
return NS_OK;
1278-
}
1279-
1280-
nsresult CacheFile::AddBaseDomainAccess(uint32_t aSiteID) {
1281-
CacheFileAutoLock lock(this);
1282-
1283-
nsresult rv;
1284-
1285-
LOG(("CacheFile::AddBaseDomainAccess() this=%p, siteID=%u", this, aSiteID));
1286-
1287-
MOZ_ASSERT(mMetadata);
1288-
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
1289-
1290-
uint32_t trID = CacheObserver::TelemetryReportID();
1291-
uint16_t siteIDCount = 0;
1292-
bool siteIDFound = false;
1293-
const char* elem = mMetadata->GetElement("eTLD1Access");
1294-
if (elem) {
1295-
rv = CacheFileUtils::ParseBaseDomainAccessInfo(elem, trID, &aSiteID,
1296-
&siteIDFound, &siteIDCount);
1297-
if (NS_FAILED(rv)) {
1298-
// Ignore existing element, it's not valid anymore.
1299-
elem = nullptr;
1300-
} else if (siteIDFound) {
1301-
// Access from this site is already logged, nothing to do here.
1302-
return NS_OK;
1303-
}
1304-
}
1305-
1306-
PostWriteTimer();
1307-
1308-
// This site accessed this element for the first time within this telemetry
1309-
// report ID. Add it and update count of accessing site in the index.
1310-
++siteIDCount;
1311-
1312-
nsAutoCString newElem;
1313-
CacheFileUtils::BuildOrAppendBaseDomainAccessInfo(elem, trID, aSiteID,
1314-
newElem);
1315-
rv = mMetadata->SetElement("eTLD1Access", newElem.get());
1316-
if (NS_WARN_IF(NS_FAILED(rv))) {
1317-
return rv;
1318-
}
1319-
1320-
if (mHandle && !mHandle->IsDoomed()) {
1321-
CacheFileIOManager::UpdateIndexEntry(mHandle, nullptr, nullptr, nullptr,
1322-
nullptr, nullptr, &siteIDCount, trID);
1274+
nullptr, &aContentType);
13231275
}
13241276
return NS_OK;
13251277
}
@@ -1350,7 +1302,7 @@ nsresult CacheFile::SetAltMetadata(const char* aAltMetadata) {
13501302

13511303
if (mHandle && !mHandle->IsDoomed()) {
13521304
CacheFileIOManager::UpdateIndexEntry(mHandle, nullptr, &hasAltData, nullptr,
1353-
nullptr, nullptr, nullptr, 0);
1305+
nullptr, nullptr);
13541306
}
13551307
return rv;
13561308
}
@@ -2586,17 +2538,9 @@ nsresult CacheFile::InitIndexEntry() {
25862538
contentType = n64;
25872539
}
25882540

2589-
uint32_t trID = CacheObserver::TelemetryReportID();
2590-
const char* siteIDInfo = mMetadata->GetElement("eTLD1Access");
2591-
uint16_t siteIDCount = 0;
2592-
if (siteIDInfo) {
2593-
CacheFileUtils::ParseBaseDomainAccessInfo(siteIDInfo, trID, nullptr,
2594-
nullptr, &siteIDCount);
2595-
}
2596-
25972541
rv = CacheFileIOManager::UpdateIndexEntry(mHandle, &frecency, &hasAltData,
25982542
&onStartTime, &onStopTime,
2599-
&contentType, &siteIDCount, trID);
2543+
&contentType);
26002544
NS_ENSURE_SUCCESS(rv, rv);
26012545

26022546
return NS_OK;

netwerk/cache2/CacheFile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class CacheFile final : public CacheFileChunkListener,
102102
nsresult GetFrecency(uint32_t* _retval);
103103
nsresult SetNetworkTimes(uint64_t aOnStartTime, uint64_t aOnStopTime);
104104
nsresult SetContentType(uint8_t aContentType);
105-
nsresult AddBaseDomainAccess(uint32_t aSiteID);
106105
nsresult GetOnStartTime(uint64_t* _retval);
107106
nsresult GetOnStopTime(uint64_t* _retval);
108107
nsresult GetLastModified(uint32_t* _retval);

netwerk/cache2/CacheFileIOManager.cpp

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ class InitIndexEntryEvent : public Runnable {
972972
// if there is no write to the file.
973973
uint32_t sizeInK = mHandle->FileSizeInK();
974974
CacheIndex::UpdateEntry(mHandle->Hash(), nullptr, nullptr, nullptr, nullptr,
975-
nullptr, nullptr, 0, &sizeInK);
975+
nullptr, &sizeInK);
976976

977977
return NS_OK;
978978
}
@@ -989,24 +989,19 @@ class UpdateIndexEntryEvent : public Runnable {
989989
UpdateIndexEntryEvent(CacheFileHandle* aHandle, const uint32_t* aFrecency,
990990
const bool* aHasAltData, const uint16_t* aOnStartTime,
991991
const uint16_t* aOnStopTime,
992-
const uint8_t* aContentType,
993-
const uint16_t* aBaseDomainAccessCount,
994-
const uint32_t aTelemetryReportID)
992+
const uint8_t* aContentType)
995993
: Runnable("net::UpdateIndexEntryEvent"),
996994
mHandle(aHandle),
997995
mHasFrecency(false),
998996
mHasHasAltData(false),
999997
mHasOnStartTime(false),
1000998
mHasOnStopTime(false),
1001999
mHasContentType(false),
1002-
mHasBaseDomainAccessCount(false),
10031000
mFrecency(0),
10041001
mHasAltData(false),
10051002
mOnStartTime(0),
10061003
mOnStopTime(0),
1007-
mContentType(nsICacheEntry::CONTENT_TYPE_UNKNOWN),
1008-
mBaseDomainAccessCount(0),
1009-
mTelemetryReportID(aTelemetryReportID) {
1004+
mContentType(nsICacheEntry::CONTENT_TYPE_UNKNOWN) {
10101005
if (aFrecency) {
10111006
mHasFrecency = true;
10121007
mFrecency = *aFrecency;
@@ -1027,10 +1022,6 @@ class UpdateIndexEntryEvent : public Runnable {
10271022
mHasContentType = true;
10281023
mContentType = *aContentType;
10291024
}
1030-
if (aBaseDomainAccessCount) {
1031-
mHasBaseDomainAccessCount = true;
1032-
mBaseDomainAccessCount = *aBaseDomainAccessCount;
1033-
}
10341025
}
10351026

10361027
protected:
@@ -1048,8 +1039,7 @@ class UpdateIndexEntryEvent : public Runnable {
10481039
mHasOnStartTime ? &mOnStartTime : nullptr,
10491040
mHasOnStopTime ? &mOnStopTime : nullptr,
10501041
mHasContentType ? &mContentType : nullptr,
1051-
mHasBaseDomainAccessCount ? &mBaseDomainAccessCount : nullptr,
1052-
mTelemetryReportID, nullptr);
1042+
nullptr);
10531043
return NS_OK;
10541044
}
10551045

@@ -1061,15 +1051,12 @@ class UpdateIndexEntryEvent : public Runnable {
10611051
bool mHasOnStartTime;
10621052
bool mHasOnStopTime;
10631053
bool mHasContentType;
1064-
bool mHasBaseDomainAccessCount;
10651054

10661055
uint32_t mFrecency;
10671056
bool mHasAltData;
10681057
uint16_t mOnStartTime;
10691058
uint16_t mOnStopTime;
10701059
uint8_t mContentType;
1071-
uint16_t mBaseDomainAccessCount;
1072-
uint32_t mTelemetryReportID;
10731060
};
10741061

10751062
class MetadataWriteScheduleEvent : public Runnable {
@@ -2048,7 +2035,7 @@ nsresult CacheFileIOManager::WriteInternal(CacheFileHandle* aHandle,
20482035
if (oldSizeInK != newSizeInK && !aHandle->IsDoomed() &&
20492036
!aHandle->IsSpecialFile()) {
20502037
CacheIndex::UpdateEntry(aHandle->Hash(), nullptr, nullptr, nullptr,
2051-
nullptr, nullptr, nullptr, 0, &newSizeInK);
2038+
nullptr, nullptr, &newSizeInK);
20522039

20532040
if (oldSizeInK < newSizeInK) {
20542041
EvictIfOverLimitInternal();
@@ -2564,7 +2551,7 @@ nsresult CacheFileIOManager::TruncateSeekSetEOFInternal(
25642551
if (oldSizeInK != newSizeInK && !aHandle->IsDoomed() &&
25652552
!aHandle->IsSpecialFile()) {
25662553
CacheIndex::UpdateEntry(aHandle->Hash(), nullptr, nullptr, nullptr, nullptr,
2567-
nullptr, nullptr, 0, &newSizeInK);
2554+
nullptr, &newSizeInK);
25682555

25692556
if (oldSizeInK < newSizeInK) {
25702557
EvictIfOverLimitInternal();
@@ -2878,7 +2865,7 @@ nsresult CacheFileIOManager::OverLimitEvictionInternal() {
28782865
// failing on one entry forever.
28792866
uint32_t frecency = 0;
28802867
rv = CacheIndex::UpdateEntry(&hash, &frecency, nullptr, nullptr, nullptr,
2881-
nullptr, nullptr, 0, nullptr);
2868+
nullptr, nullptr);
28822869
NS_ENSURE_SUCCESS(rv, rv);
28832870

28842871
consecutiveFailures++;
@@ -3533,21 +3520,15 @@ nsresult CacheFileIOManager::InitIndexEntry(CacheFileHandle* aHandle,
35333520
nsresult CacheFileIOManager::UpdateIndexEntry(
35343521
CacheFileHandle* aHandle, const uint32_t* aFrecency,
35353522
const bool* aHasAltData, const uint16_t* aOnStartTime,
3536-
const uint16_t* aOnStopTime, const uint8_t* aContentType,
3537-
const uint16_t* aBaseDomainAccessCount, const uint32_t aTelemetryReportID) {
3523+
const uint16_t* aOnStopTime, const uint8_t* aContentType) {
35383524
LOG(
35393525
("CacheFileIOManager::UpdateIndexEntry() [handle=%p, frecency=%s, "
3540-
"hasAltData=%s, onStartTime=%s, onStopTime=%s, contentType=%s, "
3541-
"baseDomainAccessCount=%s, telemetryReportID=%u]",
3526+
"hasAltData=%s, onStartTime=%s, onStopTime=%s, contentType=%s]",
35423527
aHandle, aFrecency ? nsPrintfCString("%u", *aFrecency).get() : "",
35433528
aHasAltData ? (*aHasAltData ? "true" : "false") : "",
35443529
aOnStartTime ? nsPrintfCString("%u", *aOnStartTime).get() : "",
35453530
aOnStopTime ? nsPrintfCString("%u", *aOnStopTime).get() : "",
3546-
aContentType ? nsPrintfCString("%u", *aContentType).get() : "",
3547-
aBaseDomainAccessCount
3548-
? nsPrintfCString("%u", *aBaseDomainAccessCount).get()
3549-
: "",
3550-
aTelemetryReportID));
3531+
aContentType ? nsPrintfCString("%u", *aContentType).get() : ""));
35513532

35523533
nsresult rv;
35533534
RefPtr<CacheFileIOManager> ioMan = gInstance;
@@ -3561,8 +3542,7 @@ nsresult CacheFileIOManager::UpdateIndexEntry(
35613542
}
35623543

35633544
RefPtr<UpdateIndexEntryEvent> ev = new UpdateIndexEntryEvent(
3564-
aHandle, aFrecency, aHasAltData, aOnStartTime, aOnStopTime, aContentType,
3565-
aBaseDomainAccessCount, aTelemetryReportID);
3545+
aHandle, aFrecency, aHasAltData, aOnStartTime, aOnStopTime, aContentType);
35663546
rv = ioMan->mIOThread->Dispatch(ev, aHandle->mPriority
35673547
? CacheIOThread::WRITE_PRIORITY
35683548
: CacheIOThread::WRITE);

netwerk/cache2/CacheFileIOManager.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ class CacheFileIOManager final : public nsITimerCallback, public nsINamed {
323323
const bool* aHasAltData,
324324
const uint16_t* aOnStartTime,
325325
const uint16_t* aOnStopTime,
326-
const uint8_t* aContentType,
327-
const uint16_t* aBaseDomainAccessCount,
328-
const uint32_t aTelemetryReportID);
326+
const uint8_t* aContentType);
329327

330328
static nsresult UpdateIndexEntry();
331329

netwerk/cache2/CacheFileUtils.cpp

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ namespace CacheFileUtils {
2323
static uint32_t const kAltDataVersion = 1;
2424
const char* kAltDataKey = "alt-data";
2525

26-
static uint32_t const kBaseDomainAccessInfoVersion = 1;
27-
2826
namespace {
2927

3028
/**
@@ -664,68 +662,6 @@ void BuildAlternativeDataInfo(const char* aInfo, int64_t aOffset,
664662
_retval.Append(aInfo);
665663
}
666664

667-
nsresult ParseBaseDomainAccessInfo(const char* aInfo, uint32_t aTrID,
668-
const uint32_t* aSearchSiteID, bool* _found,
669-
uint16_t* _count) {
670-
// The format is: "1;12;339456,490536687,1964820,"
671-
// <version>;<telemetry_report_ID>;<siteID>,<siteID>,
672-
mozilla::Tokenizer p(aInfo);
673-
uint32_t i = 0;
674-
uint16_t siteIDCnt = 0;
675-
676-
// Check version and telemetry report ID
677-
if (!p.ReadInteger(&i) || i != kBaseDomainAccessInfoVersion ||
678-
!p.CheckChar(';') || !p.ReadInteger(&i) || i != aTrID ||
679-
!p.CheckChar(';')) {
680-
LOG(
681-
("ParseBaseDomainAccessInfo() - cannot parse info [info=%s, version=%u,"
682-
" trID=%u]",
683-
aInfo, kBaseDomainAccessInfoVersion, aTrID));
684-
return NS_ERROR_NOT_AVAILABLE;
685-
}
686-
687-
do {
688-
if (!p.ReadInteger(&i) || !p.CheckChar(',')) {
689-
LOG(
690-
("ParseBaseDomainAccessInfo() - cannot parse site ID [info=%s, "
691-
"siteIDCnt=%d]",
692-
aInfo, siteIDCnt));
693-
return NS_ERROR_NOT_AVAILABLE;
694-
}
695-
696-
// If aSearchSiteID was provided, we don't need the total count of IDs.
697-
// Just return true and don't process the rest of data.
698-
if (aSearchSiteID && *aSearchSiteID == i) {
699-
*_found = true;
700-
return NS_OK;
701-
}
702-
703-
++siteIDCnt;
704-
} while (!p.CheckEOF());
705-
706-
if (_count) {
707-
*_count = siteIDCnt;
708-
}
709-
710-
return NS_OK;
711-
}
712-
713-
void BuildOrAppendBaseDomainAccessInfo(const char* aOldInfo, uint32_t aTrID,
714-
uint32_t aSiteID, nsACString& _retval) {
715-
if (aOldInfo) {
716-
_retval.Assign(aOldInfo);
717-
} else {
718-
_retval.Truncate();
719-
_retval.AppendInt(kBaseDomainAccessInfoVersion);
720-
_retval.Append(';');
721-
_retval.AppendInt(aTrID);
722-
_retval.Append(';');
723-
}
724-
725-
_retval.AppendInt(aSiteID);
726-
_retval.Append(',');
727-
}
728-
729665
} // namespace CacheFileUtils
730666
} // namespace net
731667
} // namespace mozilla

netwerk/cache2/CacheFileUtils.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,6 @@ nsresult ParseAlternativeDataInfo(const char* aInfo, int64_t* _offset,
217217
void BuildAlternativeDataInfo(const char* aInfo, int64_t aOffset,
218218
nsACString& _retval);
219219

220-
// Parses base domain access info. If the info cannot be parsed (e.g. it's
221-
// corrupted or it's invalid because aTrID has changed) an error is thrown.
222-
// If aSearchSiteID is null, then the whole string is parsed and number of sites
223-
// in the info is returned in _count.
224-
// If aSearchSiteID is passed, then _count argument is ignored. It only searches
225-
// siteID in the info and returns the result in _found.
226-
nsresult ParseBaseDomainAccessInfo(const char* aInfo, uint32_t aTrID,
227-
const uint32_t* aSearchSiteID, bool* _found,
228-
uint16_t* _count);
229-
230-
// If aOldInfo is null then new base domain access info containing aSiteID is
231-
// built. If an old base domain access info is passed in aOldInfo, then only
232-
// aSiteID is appended to it. Note that this function doesn't parse the old base
233-
// domain info, i.e. it assumes that it's valid and it doesn't contain aSiteID.
234-
void BuildOrAppendBaseDomainAccessInfo(const char* aOldInfo, uint32_t aTrID,
235-
uint32_t aSiteID, nsACString& _retval);
236-
237220
} // namespace CacheFileUtils
238221
} // namespace net
239222
} // namespace mozilla

0 commit comments

Comments
 (0)