Skip to content

Commit

Permalink
Fix flakes with weblayer browsertests.
Browse files Browse the repository at this point in the history
This only seemed to come up on Windows debug and not other desktop platforms, possibly related to timing. The user-data-dir override wasn't set on desktop and so tests in parallel shared a data directory.

Bug: 1026523
Change-Id: Ifddf92266e63a2742c8806aabbf9c0dbdb94d42a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940718
Auto-Submit: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719711}
  • Loading branch information
John Abd-El-Malek authored and Commit Bot committed Nov 27, 2019
1 parent 1de601a commit d0077f3
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions weblayer/app/content_main_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,31 @@ void ContentMainDelegateImpl::PreSandboxStartup() {
base::CPU cpu_info;
#endif

const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
bool is_browser_process =
command_line.GetSwitchValueASCII(switches::kProcessType).empty();
if (is_browser_process &&
command_line.HasSwitch(switches::kWebLayerUserDataDir)) {
base::FilePath path =
command_line.GetSwitchValuePath(switches::kWebLayerUserDataDir);
if (base::DirectoryExists(path) || base::CreateDirectory(path)) {
// Profile needs an absolute path, which we would normally get via
// PathService. In this case, manually ensure the path is absolute.
if (!path.IsAbsolute())
path = base::MakeAbsoluteFilePath(path);
} else {
LOG(ERROR) << "Unable to create data-path directory: " << path.value();
}
CHECK(base::PathService::OverrideAndCreateIfNeeded(
weblayer::DIR_USER_DATA, path, true /* is_absolute */,
false /* create */));
}

InitializeResourceBundle();

#if defined(OS_ANDROID)
EnableCrashReporter(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType));
EnableCrashReporter(command_line.GetSwitchValueASCII(switches::kProcessType));
SetWebLayerCrashKeys();
#endif
}
Expand Down Expand Up @@ -233,22 +252,6 @@ void ContentMainDelegateImpl::InitializeResourceBundle() {
base::GlobalDescriptors::GetInstance()->Set(
kWebLayerSecondaryLocalePakDescriptor, fd, region);
}

if (command_line.HasSwitch(switches::kWebLayerUserDataDir)) {
base::FilePath path =
command_line.GetSwitchValuePath(switches::kWebLayerUserDataDir);
if (base::DirectoryExists(path) || base::CreateDirectory(path)) {
// Profile needs an absolute path, which we would normally get via
// PathService. In this case, manually ensure the path is absolute.
if (!path.IsAbsolute())
path = base::MakeAbsoluteFilePath(path);
} else {
LOG(ERROR) << "Unable to create data-path directory: " << path.value();
}
CHECK(base::PathService::OverrideAndCreateIfNeeded(
weblayer::DIR_USER_DATA, path, true /* is_absolute */,
false /* create */));
}
} else {
base::i18n::SetICUDefaultLocale(
command_line.GetSwitchValueASCII(switches::kLang));
Expand Down

0 comments on commit d0077f3

Please sign in to comment.