Skip to content

Commit

Permalink
Bug 1782557: Get sponsored session timeout pref only when needed. r=e…
Browse files Browse the repository at this point in the history
…milio

Differential Revision: https://phabricator.services.mozilla.com/D153421
  • Loading branch information
Daisuke Akatsuka committed Aug 3, 2022
1 parent 417eb46 commit afb41c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ add_task(async function timeout() {

info("Set timeout second");
await SpecialPowers.pushPrefEnv({
set: [["places.sponsoredSession.timeOutSec", 1]],
set: [["browser.places.sponsoredSession.timeoutSecs", 1]],
});

info("Wait 1 sec");
Expand Down
6 changes: 6 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,12 @@
value: 5000
mirror: always

# Number of seconds till the sponsored session is timeout.
- name: browser.places.sponsoredSession.timeoutSecs
type: RelaxedAtomicUint32
value: 3600
mirror: always

# Force usage of in-memory (rather than file on disk) media cache for video streaming when private browsing
- name: browser.privatebrowsing.forceMediaMemoryCache
type: bool
Expand Down
11 changes: 3 additions & 8 deletions toolkit/components/places/History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include "nsIBrowserWindowTracker.h"
#include "nsImportModule.h"
#include "mozilla/StaticPrefs_browser.h"

using namespace mozilla::dom;
using namespace mozilla::ipc;
Expand Down Expand Up @@ -1024,11 +1025,6 @@ class InsertVisitedURIs final : public Runnable {
"Passed a VisitData with a URI we cannot add to history!");
}
#endif

// Need to get session timeout pref here since static call for Preferences
// should run on main thread.
mSponsoredSessionTimeoutSec = Preferences::GetUint(
"places.sponsoredSession.timeOutSec", 3600 /* Default 1 hour */);
}

/**
Expand Down Expand Up @@ -1224,7 +1220,8 @@ class InsertVisitedURIs final : public Runnable {

if ((aPlace.visitTime -
aPlace.triggeringSponsoredURLVisitTimeMS * PR_USEC_PER_MSEC) >
mSponsoredSessionTimeoutSec * PR_USEC_PER_SEC) {
StaticPrefs::browser_places_sponsoredSession_timeoutSecs() *
PR_USEC_PER_SEC) {
// Sponsored session timeout.
return NS_OK;
}
Expand Down Expand Up @@ -1279,8 +1276,6 @@ class InsertVisitedURIs final : public Runnable {

uint32_t mSuccessfulUpdatedCount;

uint32_t mSponsoredSessionTimeoutSec;

/**
* Strong reference to the History object because we do not want it to
* disappear out from under us.
Expand Down

0 comments on commit afb41c8

Please sign in to comment.