0
Files
src/content/browser/browser_thread_browsertest.cc
Etienne Pierre-doray 8439625b8b [task] Merge kCompositing into kDisplayCritical
This is a no-op on most platforms because kDisplayCritical and kCompositing are equivalent already, as desired after progress
on crbug.com/1329208

On Linux and Fuchsia: kDisplayCritical is not equivalent to kCompositing, so this CL introduces change in behavior.

On Linux, this CL aligns behavior to ChromeOS (ChromeOS is already
running kCompositing threads with the same priority as kDisplayCritical).
Population is generally too small to draw reliable conclusion from
an experiment, so it's more robust to align with ChromeOS.
On Fuchsia, we simply drop kCompositing.
Effectively, this CL brings all kCompositing threads (each process' main thread, compositor thread and IO thread) to a higher priority than it was before.

Bug: 1329208
Change-Id: I6331a3eacb2396117e20d833eb993a91eadd1d47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4842549
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1344860}
2024-08-21 16:42:37 +00:00

64 lines
2.2 KiB
C++

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/test_utils.h"
namespace content {
class BrowserThreadPostTaskBeforeInitBrowserTest : public ContentBrowserTest {
protected:
void SetUp() override {
// This should fail because the ThreadPool + TaskExecutor weren't created
// yet.
EXPECT_DCHECK_DEATH(
GetIOThreadTaskRunner({})->PostTask(FROM_HERE, base::DoNothing()));
// Obtaining a TaskRunner should also fail.
EXPECT_DCHECK_DEATH(GetIOThreadTaskRunner({}));
ContentBrowserTest::SetUp();
}
};
IN_PROC_BROWSER_TEST_F(BrowserThreadPostTaskBeforeInitBrowserTest,
ExpectFailures) {}
IN_PROC_BROWSER_TEST_F(ContentBrowserTest, ExpectedThreadPriorities) {
base::ThreadPriorityForTest expected_priority;
// In browser main loop the kDisplayCritical thread type is set.
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
// TODO(40230522): ChromeOS and Linux result a kNormal priority unexpectedly.
expected_priority = base::ThreadPriorityForTest::kNormal;
#else
expected_priority = base::ThreadPriorityForTest::kDisplay;
#endif
EXPECT_EQ(base::PlatformThread::GetCurrentThreadPriorityForTest(),
expected_priority);
GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(
[](base::ThreadPriorityForTest expected_priority) {
EXPECT_EQ(base::PlatformThread::GetCurrentThreadPriorityForTest(),
expected_priority);
},
expected_priority));
BrowserThread::RunAllPendingTasksOnThreadForTesting(BrowserThread::IO);
}
} // namespace content