Commit 9fd73cca authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

bfcache: Check for blocklisted features in CanStoreRenderFrameHostLater

This CL make us check for blocklisted features in
CanStoreRenderFrameHostLater, which is called when determining whether
we should do a proactive BrowsingInstance swap or not.

We don't currently have support for knowing that a blocklisted API is no
longer used after pagehide. This means if a blocklisted feature before
navigation, it will always be ineligible for bfcache. We should not try
to do a BrowsingInstance swap, etc. in this case.

In the future, as we add support for blocklisted APIs to be deemed
as no longer used after it was torn down in pagehide, we can move the
check for the newly supported APIs one by one to
CanStoreRenderFrameHostNow.

More context: https://groups.google.com/a/google.com/g/chrome-bfcache/c/L-ZreZDY4n0/m/8cBbBGB5CQAJ

Bug: 1129331
Change-Id: Ic1756d8c8460036dc97603b38b4251fb7894f9fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442397
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuzu Saijo <yuzus@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813505}
parent 0a8fae01
......@@ -336,8 +336,16 @@ class BackForwardCacheBrowserTest : public ContentBrowserTest,
void ExpectBlocklistedFeature(
blink::scheduler::WebSchedulerTrackedFeature feature,
base::Location location) {
ExpectBlocklistedFeatures({feature}, location);
}
void ExpectBlocklistedFeatures(
std::vector<blink::scheduler::WebSchedulerTrackedFeature> features,
base::Location location) {
for (auto feature : features) {
base::HistogramBase::Sample sample = base::HistogramBase::Sample(feature);
AddSampleToBuckets(&expected_blocklisted_features_, sample);
}
EXPECT_THAT(histogram_tester_.GetAllSamples(
"BackForwardCache.HistoryNavigationOutcome."
......@@ -2379,6 +2387,294 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
blink::scheduler::WebSchedulerTrackedFeature::kKeyboardLock, FROM_HERE);
}
// Tests which blocklisted features are tracked in the metrics when we used
// blocklisted features (sticky and non-sticky) and do a browser-initiated
// cross-site navigation.
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_BrowserInitiated) {
ASSERT_TRUE(CreateHttpsServer()->Start());
GURL url_a(https_server()->GetURL("a.com", "/title1.html"));
GURL url_b(https_server()->GetURL("b.com", "/title2.html"));
// 1) Navigate to a page.
EXPECT_TRUE(NavigateToURL(shell(), url_a));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_a = current_frame_host();
scoped_refptr<SiteInstanceImpl> site_instance_a =
static_cast<SiteInstanceImpl*>(rfh_a->GetSiteInstance());
RenderFrameDeletedObserver rfh_a_deleted(rfh_a);
// 2) Use WebRTC (non-sticky) and KeyboardLock (sticky) blocklisted features.
EXPECT_TRUE(ExecJs(rfh_a, "new RTCPeerConnection()"));
EXPECT_TRUE(ExecJs(rfh_a, R"(
new Promise(resolve => {
navigator.keyboard.lock();
resolve();
});
)"));
// 3) Navigate cross-site, browser-initiated.
EXPECT_TRUE(NavigateToURL(shell(), url_b));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// The previous page won't get into the back-forward cache because of the
// blocklisted features. Because we used sticky blocklisted features, we will
// not do a proactive BrowsingInstance swap, however the RFH will still change
// and get deleted.
rfh_a_deleted.WaitUntilDeleted();
EXPECT_FALSE(site_instance_a->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
ExpectNotRestored(
{BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures},
FROM_HERE);
// All features (sticky and non-sticky) will be tracked, because they're
// tracked in RenderFrameHostManager::UnloadOldFrame.
ExpectBlocklistedFeatures(
{blink::scheduler::WebSchedulerTrackedFeature::kWebRTC,
blink::scheduler::WebSchedulerTrackedFeature::kKeyboardLock},
FROM_HERE);
}
// Tests which blocklisted features are tracked in the metrics when we used
// blocklisted features (sticky and non-sticky) and do a renderer-initiated
// cross-site navigation.
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_RendererInitiated) {
ASSERT_TRUE(CreateHttpsServer()->Start());
GURL url_a(https_server()->GetURL("a.com", "/title1.html"));
GURL url_b(https_server()->GetURL("b.com", "/title2.html"));
// 1) Navigate to a page.
EXPECT_TRUE(NavigateToURL(shell(), url_a));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_a = current_frame_host();
scoped_refptr<SiteInstanceImpl> site_instance_a =
static_cast<SiteInstanceImpl*>(rfh_a->GetSiteInstance());
// 2) Use WebRTC (non-sticky) and KeyboardLock (sticky) blocklisted
// features.
EXPECT_TRUE(ExecJs(rfh_a, "new RTCPeerConnection()"));
EXPECT_TRUE(ExecJs(rfh_a, R"(
new Promise(resolve => {
navigator.keyboard.lock();
resolve();
});
)"));
// 3) Navigate cross-site, renderer-inititated.
EXPECT_TRUE(ExecJs(shell(), JsReplace("location = $1;", url_b.spec())));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// The previous page won't get into the back-forward cache because of the
// blocklisted features. Because we used sticky blocklisted features, we will
// not do a proactive BrowsingInstance swap.
EXPECT_TRUE(site_instance_a->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
if (AreAllSitesIsolatedForTesting()) {
ExpectNotRestored(
{BackForwardCacheMetrics::NotRestoredReason::
kRelatedActiveContentsExist,
BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures},
FROM_HERE);
// All features (sticky and non-sticky) will be tracked, because they're
// tracked in RenderFrameHostManager::UnloadOldFrame.
ExpectBlocklistedFeatures(
{blink::scheduler::WebSchedulerTrackedFeature::kWebRTC,
blink::scheduler::WebSchedulerTrackedFeature::kKeyboardLock},
FROM_HERE);
} else {
ExpectNotRestored({BackForwardCacheMetrics::NotRestoredReason::
kRenderFrameHostReused_CrossSite},
FROM_HERE);
}
}
// Tests which blocklisted features are tracked in the metrics when we used
// blocklisted features (sticky and non-sticky) and do a same-site navigation.
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_SameSite) {
ASSERT_TRUE(CreateHttpsServer()->Start());
ASSERT_TRUE(CreateHttpsServer()->Start());
GURL url_1(https_server()->GetURL("/title1.html"));
GURL url_2(https_server()->GetURL("/title2.html"));
// 1) Navigate to a page.
EXPECT_TRUE(NavigateToURL(shell(), url_1));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_1 = current_frame_host();
scoped_refptr<SiteInstanceImpl> site_instance_1 =
static_cast<SiteInstanceImpl*>(rfh_1->GetSiteInstance());
// 2) Use WebRTC (non-sticky) and KeyboardLock (sticky) blocklisted features.
EXPECT_TRUE(ExecJs(rfh_1, "new RTCPeerConnection()"));
EXPECT_TRUE(ExecJs(rfh_1, R"(
new Promise(resolve => {
navigator.keyboard.lock();
resolve();
});
)"));
// 3) Navigate same-site.
EXPECT_TRUE(NavigateToURL(shell(), url_2));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because we used sticky blocklisted features, we will not do a proactive
// BrowsingInstance swap.
EXPECT_TRUE(site_instance_1->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
ExpectNotRestored({BackForwardCacheMetrics::NotRestoredReason::
kRenderFrameHostReused_SameSite},
FROM_HERE);
}
// Tests which blocklisted features are tracked in the metrics when we used a
// non-sticky blocklisted feature and do a browser-initiated cross-site
// navigation.
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_BrowserInitiated_NonSticky) {
ASSERT_TRUE(CreateHttpsServer()->Start());
// 1) Navigate to an empty page.
GURL url_a(https_server()->GetURL("a.com", "/title1.html"));
GURL url_b(https_server()->GetURL("b.com", "/title2.html"));
EXPECT_TRUE(NavigateToURL(shell(), url_a));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_a = current_frame_host();
// 2) Use WebRTC (a non-sticky blocklisted feature).
EXPECT_TRUE(ExecJs(rfh_a, "new RTCPeerConnection()"));
scoped_refptr<SiteInstanceImpl> site_instance_a =
static_cast<SiteInstanceImpl*>(
web_contents()->GetMainFrame()->GetSiteInstance());
// 3) Navigate cross-site, browser-initiated.
// The previous page won't get into the back-forward cache because of the
// blocklisted feature.
EXPECT_TRUE(NavigateToURL(shell(), url_b));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because we only used non-sticky blocklisted features, we will still do a
// proactive BrowsingInstance swap.
EXPECT_FALSE(site_instance_a->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because the RenderFrameHostManager changed, the blocklisted features will
// be tracked in RenderFrameHostManager::UnloadOldFrame.
ExpectNotRestored(
{BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures},
FROM_HERE);
ExpectBlocklistedFeature(
blink::scheduler::WebSchedulerTrackedFeature::kWebRTC, FROM_HERE);
}
// Tests which blocklisted features are tracked in the metrics when we used a
// non-sticky blocklisted feature and do a renderer-initiated cross-site
// navigation.
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_RendererInitiated_NonSticky) {
ASSERT_TRUE(CreateHttpsServer()->Start());
// 1) Navigate to an empty page.
GURL url_a(https_server()->GetURL("a.com", "/title1.html"));
GURL url_b(https_server()->GetURL("b.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), url_a));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_a = current_frame_host();
// 2) Use WebRTC (a non-sticky blocklisted feature).
EXPECT_TRUE(ExecJs(rfh_a, "new RTCPeerConnection()"));
scoped_refptr<SiteInstanceImpl> site_instance_a =
static_cast<SiteInstanceImpl*>(
web_contents()->GetMainFrame()->GetSiteInstance());
// 3) Navigate cross-site, renderer-inititated.
// The previous page won't get into the back-forward cache because of the
// blocklisted feature.
EXPECT_TRUE(ExecJs(shell(), JsReplace("location = $1;", url_b.spec())));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because we only used non-sticky blocklisted features, we will still do a
// proactive BrowsingInstance swap.
EXPECT_FALSE(site_instance_a->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because the RenderFrameHostManager changed, the blocklisted features will
// be tracked in RenderFrameHostManager::UnloadOldFrame.
ExpectNotRestored(
{BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures},
FROM_HERE);
ExpectBlocklistedFeature(
blink::scheduler::WebSchedulerTrackedFeature::kWebRTC, FROM_HERE);
}
// Tests which blocklisted features are tracked in the metrics when we used a
// non-sticky blocklisted feature and do a same-site navigation.
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_SameSite_NonSticky) {
ASSERT_TRUE(CreateHttpsServer()->Start());
// 1) Navigate to an empty page.
GURL url_1(https_server()->GetURL("/title1.html"));
GURL url_2(https_server()->GetURL("/title2.html"));
EXPECT_TRUE(NavigateToURL(shell(), url_1));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
RenderFrameHostImpl* rfh_1 = current_frame_host();
// 2) Use WebRTC (a non-sticky blocklisted feature).
EXPECT_TRUE(ExecJs(rfh_1, "new RTCPeerConnection()"));
scoped_refptr<SiteInstanceImpl> site_instance_1 =
static_cast<SiteInstanceImpl*>(
web_contents()->GetMainFrame()->GetSiteInstance());
// 3) Navigate same-site.
// The previous page won't get into the back-forward cache because of the
// blocklisted feature.
EXPECT_TRUE(NavigateToURL(shell(), url_2));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because we only used non-sticky blocklisted features, we will still do a
// proactive BrowsingInstance swap.
EXPECT_FALSE(site_instance_1->IsRelatedSiteInstance(
web_contents()->GetMainFrame()->GetSiteInstance()));
// 4) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Because the RenderFrameHostManager changed, the blocklisted features will
// be tracked in RenderFrameHostManager::UnloadOldFrame.
ExpectNotRestored(
{BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures},
FROM_HERE);
ExpectBlocklistedFeature(
blink::scheduler::WebSchedulerTrackedFeature::kWebRTC, FROM_HERE);
}
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, LogIpcPostedToCachedFrame) {
ASSERT_TRUE(embedded_test_server()->Start());
......@@ -5575,9 +5871,6 @@ IN_PROC_BROWSER_TEST_F(SensorBackForwardCacheBrowserTest,
ASSERT_TRUE(NavigateToURL(shell(), url_a));
RenderFrameHostImpl* rfh_a = current_frame_host();
RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a);
scoped_refptr<SiteInstanceImpl> site_instance_a =
static_cast<SiteInstanceImpl*>(
web_contents()->GetMainFrame()->GetSiteInstance());
EXPECT_TRUE(ExecJs(rfh_a, R"(
new Promise(resolve => {
......@@ -5587,25 +5880,12 @@ IN_PROC_BROWSER_TEST_F(SensorBackForwardCacheBrowserTest,
})
)"));
// 2) Navigate to B. The navigation is renderer-initiated and should not
// create a new RenderFrameHost or BrowsingInstance unless we decided to do
// a proactive BrowsingInstance swap.
ASSERT_TRUE(NavigateToURLFromRenderer(shell(), url_b));
scoped_refptr<SiteInstanceImpl> site_instance_b =
static_cast<SiteInstanceImpl*>(
web_contents()->GetMainFrame()->GetSiteInstance());
// 2) Navigate to B.
ASSERT_TRUE(NavigateToURL(shell(), url_b));
// Page A should not be in the cache, because it uses accelerometer, which is
// a blocklisted feature for bfcache.
// - Page A should not be in the cache.
delete_observer_rfh_a.WaitUntilDeleted();
// We should've done a proactive BrowsingInstance swap for the navigation
// from A and B even when we know that there's a blocklisted feature being
// used, because we don't account for disallowed features for bfcache
// eligibility when determining whether or not we should do a proactive
// BrowsingInstance swap.
EXPECT_FALSE(site_instance_a->IsRelatedSiteInstance(site_instance_b.get()));
// 3) Go back.
web_contents()->GetController().GoBack();
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
......
......@@ -110,7 +110,10 @@ bool ShouldIgnoreBlocklists() {
return should_ignore_blocklists.Get();
}
uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh) {
enum RequestedFeatures { kAll, kOnlySticky };
uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh,
RequestedFeatures requested_features) {
// TODO(https://crbug.com/1015784): Finalize disallowed feature list, and test
// for each disallowed feature.
constexpr uint64_t kAlwaysDisallowedFeatures =
......@@ -170,6 +173,11 @@ uint64_t GetDisallowedFeatures(RenderFrameHostImpl* rfh) {
FeatureToBit(WebSchedulerTrackedFeature::kOutstandingNetworkRequestXHR);
}
if (requested_features == RequestedFeatures::kOnlySticky) {
// Remove all non-sticky features from |result|.
result &= blink::scheduler::StickyFeaturesBitmask();
}
return result;
}
......@@ -435,6 +443,18 @@ void BackForwardCacheImpl::CanStoreRenderFrameHostLater(
if (rfh->IsOuterDelegateFrame())
result->No(BackForwardCacheMetrics::NotRestoredReason::kHaveInnerContents);
// When it's not the final decision for putting a page in the back-forward
// cache, we should only consider "sticky" features here - features that
// will always result in a page becoming ineligible for back-forward cache
// since the first time it's used.
if (uint64_t banned_features =
GetDisallowedFeatures(rfh, RequestedFeatures::kOnlySticky) &
rfh->scheduler_tracked_features()) {
if (!ShouldIgnoreBlocklists()) {
result->NoDueToFeatures(banned_features);
}
}
for (size_t i = 0; i < rfh->child_count(); i++)
CanStoreRenderFrameHostLater(result,
rfh->child_at(i)->current_frame_host());
......@@ -448,11 +468,14 @@ void BackForwardCacheImpl::CheckDynamicStatesOnSubtree(
if (!rfh->IsDOMContentLoaded())
result->No(BackForwardCacheMetrics::NotRestoredReason::kLoading);
// TODO(altimin): At the moment only the first detected failure is reported.
// For reporting purposes it's a good idea to also collect this information
// from children.
// Check for banned features currently being used. Note that unlike the check
// in CanStoreRenderFrameHostLater, we are checking all banned features here
// (not only the "sticky" features), because this time we're making a final
// decision on whether we should store a page in the back-forward cache or
// not.
if (uint64_t banned_features =
GetDisallowedFeatures(rfh) & rfh->scheduler_tracked_features()) {
GetDisallowedFeatures(rfh, RequestedFeatures::kAll) &
rfh->scheduler_tracked_features()) {
if (!ShouldIgnoreBlocklists()) {
result->NoDueToFeatures(banned_features);
}
......
......@@ -114,5 +114,53 @@ const char* FeatureToString(WebSchedulerTrackedFeature feature) {
}
}
bool IsFeatureSticky(WebSchedulerTrackedFeature feature) {
return (FeatureToBit(feature) & StickyFeaturesBitmask()) > 0;
}
uint64_t StickyFeaturesBitmask() {
return FeatureToBit(
WebSchedulerTrackedFeature::kMainResourceHasCacheControlNoStore) |
FeatureToBit(
WebSchedulerTrackedFeature::kMainResourceHasCacheControlNoCache) |
FeatureToBit(
WebSchedulerTrackedFeature::kSubresourceHasCacheControlNoStore) |
FeatureToBit(
WebSchedulerTrackedFeature::kSubresourceHasCacheControlNoCache) |
FeatureToBit(WebSchedulerTrackedFeature::kPageShowEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kPageHideEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kBeforeUnloadEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kUnloadEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kFreezeEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kResumeEventListener) |
FeatureToBit(WebSchedulerTrackedFeature::kContainsPlugins) |
FeatureToBit(WebSchedulerTrackedFeature::kDocumentLoaded) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedGeolocationPermission) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedNotificationsPermission) |
FeatureToBit(WebSchedulerTrackedFeature::kRequestedMIDIPermission) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedAudioCapturePermission) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedVideoCapturePermission) |
FeatureToBit(WebSchedulerTrackedFeature::
kRequestedBackForwardCacheBlockedSensors) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedBackgroundWorkPermission) |
FeatureToBit(WebSchedulerTrackedFeature::kWebLocks) |
FeatureToBit(
WebSchedulerTrackedFeature::kRequestedStorageAccessGrant) |
FeatureToBit(WebSchedulerTrackedFeature::kWebNfc) |
FeatureToBit(WebSchedulerTrackedFeature::kWebFileSystem) |
FeatureToBit(WebSchedulerTrackedFeature::kAppBanner) |
FeatureToBit(WebSchedulerTrackedFeature::kPrinting) |
FeatureToBit(WebSchedulerTrackedFeature::kPictureInPicture) |
FeatureToBit(WebSchedulerTrackedFeature::kIdleManager) |
FeatureToBit(WebSchedulerTrackedFeature::kPaymentManager) |
FeatureToBit(WebSchedulerTrackedFeature::kKeyboardLock) |
FeatureToBit(WebSchedulerTrackedFeature::kSmsService);
}
} // namespace scheduler
} // namespace blink
......@@ -115,6 +115,13 @@ BLINK_COMMON_EXPORT constexpr uint64_t FeatureToBit(
return 1ull << static_cast<uint32_t>(feature);
}
// Sticky features can't be unregistered and remain active for the rest of the
// lifetime of the page.
BLINK_COMMON_EXPORT bool IsFeatureSticky(WebSchedulerTrackedFeature feature);
// All the sticky features in bitmask form.
BLINK_COMMON_EXPORT uint64_t StickyFeaturesBitmask();
} // namespace scheduler
} // namespace blink
......
......@@ -28,7 +28,6 @@ blink_platform_sources("scheduler") {
"common/scheduler_helper.cc",
"common/scheduler_helper.h",
"common/scheduling_lifecycle_state.cc",
"common/scheduling_policy.cc",
"common/simple_thread_scheduler.cc",
"common/simple_thread_scheduler.h",
"common/single_thread_idle_task_runner.cc",
......
......@@ -52,7 +52,7 @@ FrameOrWorkerScheduler::~FrameOrWorkerScheduler() {
FrameOrWorkerScheduler::SchedulingAffectingFeatureHandle
FrameOrWorkerScheduler::RegisterFeature(SchedulingPolicy::Feature feature,
SchedulingPolicy policy) {
DCHECK(!SchedulingPolicy::IsFeatureSticky(feature));
DCHECK(!scheduler::IsFeatureSticky(feature));
// We reset feature sets upon frame navigation, so having a document-bound
// weak pointer ensures that the feature handle associated with previous
// document can't influence the new one.
......@@ -63,7 +63,7 @@ FrameOrWorkerScheduler::RegisterFeature(SchedulingPolicy::Feature feature,
void FrameOrWorkerScheduler::RegisterStickyFeature(
SchedulingPolicy::Feature feature,
SchedulingPolicy policy) {
DCHECK(SchedulingPolicy::IsFeatureSticky(feature));
DCHECK(scheduler::IsFeatureSticky(feature));
OnStartedUsingFeature(feature, policy);
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/scheduler/public/scheduling_policy.h"
namespace blink {
bool SchedulingPolicy::IsFeatureSticky(SchedulingPolicy::Feature feature) {
switch (feature) {
case Feature::kWebSocket:
case Feature::kWebRTC:
case Feature::kDedicatedWorkerOrWorklet:
case Feature::kOutstandingIndexedDBTransaction:
case Feature::kOutstandingNetworkRequestDirectSocket:
case Feature::kOutstandingNetworkRequestFetch:
case Feature::kOutstandingNetworkRequestOthers:
case Feature::kOutstandingNetworkRequestXHR:
case Feature::kBroadcastChannel:
case Feature::kIndexedDBConnection:
case Feature::kWebGL:
case Feature::kWebVR:
case Feature::kWebXR:
case Feature::kSharedWorker:
case Feature::kWebHID:
case Feature::kWebShare:
case Feature::kWebDatabase:
case Feature::kPortal:
case Feature::kSpeechRecognizer:
case Feature::kSpeechSynthesis:
case Feature::kWakeLock:
return false;
case Feature::kMainResourceHasCacheControlNoStore:
case Feature::kMainResourceHasCacheControlNoCache:
case Feature::kSubresourceHasCacheControlNoStore:
case Feature::kSubresourceHasCacheControlNoCache:
case Feature::kPageShowEventListener:
case Feature::kPageHideEventListener:
case Feature::kBeforeUnloadEventListener:
case Feature::kUnloadEventListener:
case Feature::kFreezeEventListener:
case Feature::kResumeEventListener:
case Feature::kContainsPlugins:
case Feature::kDocumentLoaded:
case Feature::kRequestedGeolocationPermission:
case Feature::kRequestedNotificationsPermission:
case Feature::kRequestedMIDIPermission:
case Feature::kRequestedAudioCapturePermission:
case Feature::kRequestedVideoCapturePermission:
case Feature::kRequestedBackForwardCacheBlockedSensors:
case Feature::kRequestedBackgroundWorkPermission:
case Feature::kWebLocks:
case Feature::kRequestedStorageAccessGrant:
case Feature::kWebNfc:
case Feature::kWebFileSystem:
case Feature::kAppBanner:
case Feature::kPrinting:
case Feature::kPictureInPicture:
case Feature::kIdleManager:
case Feature::kPaymentManager:
case Feature::kKeyboardLock:
case Feature::kSmsService:
return true;
}
}
} // namespace blink
......@@ -17,10 +17,6 @@ namespace blink {
struct PLATFORM_EXPORT SchedulingPolicy {
using Feature = scheduler::WebSchedulerTrackedFeature;
// Sticky features can't be unregistered and remain active for the rest
// of the lifetime of the page.
static bool IsFeatureSticky(Feature feature);
// List of opt-outs which form a policy.
struct DisableAllThrottling {};
struct DisableAggressiveThrottling {};
......
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