Commit de124c53 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Headless: group flags needed for virtual time mode as VirtualTime feature

This introduces a feature named "VirtualTime" and sets other command line
flags that are required for virtual time if it's enabled.

Change-Id: I0a6d30d9f47f0c59bd8ac815862b74a48448c7a8
Reviewed-on: https://chromium-review.googlesource.com/c/1340538Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609067}
parent 064574ce
specific_include_rules = {
"headless_content_main_delegate.cc": [
"+cc/base/switches.h",
"+components/viz/common/switches.h",
],
"headless_web_contents_browsertest.cc": [
"+cc/base/switches.h",
"+components/viz/common/features.h",
......
......@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/environment.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
......@@ -19,8 +20,10 @@
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "components/crash/content/app/breakpad_linux.h"
#include "components/crash/core/common/crash_key.h"
#include "components/viz/common/switches.h"
#include "content/public/browser/browser_main_runner.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/profiling.h"
......@@ -54,6 +57,12 @@
#endif
namespace headless {
namespace features {
const base::Feature kVirtualTime{"VirtualTime",
base::FEATURE_DISABLED_BY_DEFAULT};
}
namespace {
// Keep in sync with content/common/content_constants_internal.h.
#if !defined(CHROME_MULTIPLE_DLL_CHILD)
......@@ -425,4 +434,32 @@ HeadlessContentMainDelegate::CreateContentUtilityClient() {
}
#endif // !defined(CHROME_MULTIPLE_DLL_BROWSER)
void HeadlessContentMainDelegate::PostEarlyInitialization(
bool is_running_tests) {
if (base::FeatureList::IsEnabled(features::kVirtualTime)) {
// Only pass viz flags into the virtual time mode.
const char* const switches[] = {
// TODO(eseckler): Make --run-all-compositor-stages-before-draw a
// per-BeginFrame mode so that we can activate it for individual
// requests
// only. With surface sync becoming the default, we can then make
// virtual_time_enabled a per-request option, too.
// We control BeginFrames ourselves and need all compositing stages to
// run.
::switches::kRunAllCompositorStagesBeforeDraw,
::switches::kDisableNewContentRenderingTimeout,
cc::switches::kDisableThreadedAnimation,
::switches::kDisableThreadedScrolling,
// Animtion-only BeginFrames are only supported when updates from the
// impl-thread are disabled, see go/headless-rendering.
cc::switches::kDisableCheckerImaging,
// Ensure that image animations don't resync their animation timestamps
// when looping back around.
::switches::kDisableImageAnimationResync,
};
for (const auto* flag : switches)
base::CommandLine::ForCurrentProcess()->AppendSwitch(flag);
}
}
} // namespace headless
......@@ -50,6 +50,8 @@ class HEADLESS_EXPORT HeadlessContentMainDelegate
content::ContentUtilityClient* CreateContentUtilityClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
void PostEarlyInitialization(bool is_running_tests) override;
HeadlessBrowserImpl* browser() const { return browser_.get(); }
#if defined(OS_LINUX)
......
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