Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1374)

Unified Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2941123004: Remove MemoryCoordinator::CanSuspendRenderer() (Closed)
Patch Set: Fix tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_browsertest.cc
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
index 235cf5219ee9108aef9e971326e271da5675995b..17cb6c4e11266b4739c69b3e1b8f7dd2d9dce3ab 100644
--- a/content/browser/service_worker/service_worker_browsertest.cc
+++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -31,7 +31,6 @@
#include "content/browser/cache_storage/cache_storage_cache_handle.h"
#include "content/browser/cache_storage/cache_storage_context_impl.h"
#include "content/browser/cache_storage/cache_storage_manager.h"
-#include "content/browser/memory/memory_coordinator_impl.h"
#include "content/browser/service_worker/embedded_worker_instance.h"
#include "content/browser/service_worker/embedded_worker_registry.h"
#include "content/browser/service_worker/embedded_worker_status.h"
@@ -2972,68 +2971,4 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerDisableWebSecurityTest, UpdateNoCrash) {
RunTestWithCrossOriginURL(kPageUrl, kScopeUrl);
}
-class MemoryCoordinatorWithServiceWorkerTest
- : public ServiceWorkerVersionBrowserTest {
- public:
- MemoryCoordinatorWithServiceWorkerTest() {}
-
- void SetUp() override {
- scoped_feature_list_.InitAndEnableFeature(features::kMemoryCoordinator);
- ServiceWorkerVersionBrowserTest::SetUp();
- }
-
- private:
- base::test::ScopedFeatureList scoped_feature_list_;
-
- DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorWithServiceWorkerTest);
-};
-
-class TestMemoryCoordinatorDelegate : public MemoryCoordinatorDelegate {
- public:
- TestMemoryCoordinatorDelegate() {}
- ~TestMemoryCoordinatorDelegate() override {}
-
- bool CanSuspendBackgroundedRenderer(int render_process_id) override {
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestMemoryCoordinatorDelegate);
-};
-
-// MemoryCoordinatorWithServiceWorkerTest checks if a process won't be
-// suspended when it has one or more shared workers or service workers.
-// TODO(shimazu): Enable these tests on macos when MemoryMonitorMac is
-// implemented.
-#if !defined(OS_MACOSX)
-IN_PROC_BROWSER_TEST_F(MemoryCoordinatorWithServiceWorkerTest,
- CannotSuspendRendererWithServiceWorker) {
- StartServerAndNavigateToSetup();
- InstallTestHelper("/service_worker/fetch_event.js", SERVICE_WORKER_OK);
- ActivateTestHelper("/service_worker/fetch_event.js", SERVICE_WORKER_OK);
-
- MemoryCoordinatorImpl* memory_coordinator =
- MemoryCoordinatorImpl::GetInstance();
- memory_coordinator->SetDelegateForTesting(
- base::MakeUnique<TestMemoryCoordinatorDelegate>());
-
- // Ensure only one process host exists.
- ASSERT_EQ(1, CountRenderProcessHosts());
- ASSERT_EQ(1u, memory_coordinator->children().size());
-
- // Check the number of workers.
- int render_process_id = memory_coordinator->children().begin()->first;
- RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id);
- EXPECT_EQ(1u, rph->GetWorkerRefCount());
-
- // A process should be backgrounded to ensure the worker reference count takes
- // effect in CanSuspendRenderer().
- shell()->web_contents()->WasHidden();
- EXPECT_TRUE(rph->IsProcessBackgrounded());
-
- // The process which has service worker thread shouldn't be suspended.
- EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id));
-}
-#endif
-
} // namespace content
« no previous file with comments | « content/browser/memory/memory_coordinator_impl_unittest.cc ('k') | content/public/browser/memory_coordinator_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698