Commit 41d3de78 authored by Wez's avatar Wez Committed by Chromium LUCI CQ

[fuchsia] Support CreateContextParams data_quota_bytes field.

Bug: 1071393
Bug: b/154204041
Test: web_engine_unittests
Change-Id: I3ba86964279ef7f467506d0781bee1e75b169a0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2571699
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833805}
parent 51e15805
...@@ -265,6 +265,8 @@ void ContextProviderImpl::Create( ...@@ -265,6 +265,8 @@ void ContextProviderImpl::Create(
launch_options.handles_to_transfer.push_back( launch_options.handles_to_transfer.push_back(
{kContextRequestHandleId, context_request.channel().get()}); {kContextRequestHandleId, context_request.channel().get()});
base::CommandLine launch_command(*base::CommandLine::ForCurrentProcess());
// Bind |data_directory| to /data directory, if provided. // Bind |data_directory| to /data directory, if provided.
zx::channel data_directory_channel; zx::channel data_directory_channel;
if (params.has_data_directory()) { if (params.has_data_directory()) {
...@@ -285,10 +287,13 @@ void ContextProviderImpl::Create( ...@@ -285,10 +287,13 @@ void ContextProviderImpl::Create(
} }
launch_options.paths_to_transfer.push_back( launch_options.paths_to_transfer.push_back(
base::PathToTransfer{data_path, data_directory_channel.release()}); base::PathToTransfer{data_path, data_directory_channel.release()});
}
base::CommandLine launch_command = *base::CommandLine::ForCurrentProcess(); if (params.has_data_quota_bytes()) {
std::vector<zx::channel> devtools_listener_channels; launch_command.AppendSwitchNative(
switches::kDataQuotaBytes,
base::NumberToString(params.data_quota_bytes()));
}
}
// Process command-line settings specified in our package config-data. // Process command-line settings specified in our package config-data.
base::Value web_engine_config; base::Value web_engine_config;
...@@ -310,6 +315,7 @@ void ContextProviderImpl::Create( ...@@ -310,6 +315,7 @@ void ContextProviderImpl::Create(
base::NumberToString(params.remote_debugging_port())); base::NumberToString(params.remote_debugging_port()));
} }
std::vector<zx::channel> devtools_listener_channels;
if (devtools_listeners_.size() != 0) { if (devtools_listeners_.size() != 0) {
// Connect DevTools listeners to the new Context process. // Connect DevTools listeners to the new Context process.
std::vector<std::string> handles_ids; std::vector<std::string> handles_ids;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "base/test/multiprocess_test.h" #include "base/test/multiprocess_test.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "fuchsia/engine/context_provider_impl.h" #include "fuchsia/engine/context_provider_impl.h"
#include "fuchsia/engine/fake_context.h" #include "fuchsia/engine/fake_context.h"
#include "fuchsia/engine/switches.h" #include "fuchsia/engine/switches.h"
...@@ -45,9 +46,13 @@ namespace { ...@@ -45,9 +46,13 @@ namespace {
constexpr char kTestDataFileIn[] = "DataFileIn"; constexpr char kTestDataFileIn[] = "DataFileIn";
constexpr char kTestDataFileOut[] = "DataFileOut"; constexpr char kTestDataFileOut[] = "DataFileOut";
constexpr char kUrl[] = "chrome://:emorhc"; constexpr char kUrl[] = "chrome://:emorhc";
constexpr char kTitle[] = "Palindrome"; constexpr char kTitle[] = "Palindrome";
constexpr uint64_t kTestQuotaBytes = 1024;
constexpr char kTestQuotaBytesSwitchValue[] = "1024";
MULTIPROCESS_TEST_MAIN(SpawnContextServer) { MULTIPROCESS_TEST_MAIN(SpawnContextServer) {
base::test::SingleThreadTaskEnvironment task_environment( base::test::SingleThreadTaskEnvironment task_environment(
base::test::SingleThreadTaskEnvironment::MainThreadType::IO); base::test::SingleThreadTaskEnvironment::MainThreadType::IO);
...@@ -344,7 +349,7 @@ TEST_F(ContextProviderImplTest, WithProfileDir) { ...@@ -344,7 +349,7 @@ TEST_F(ContextProviderImplTest, WithProfileDir) {
fuchsia::web::CreateContextParams create_params = BuildCreateContextParams(); fuchsia::web::CreateContextParams create_params = BuildCreateContextParams();
// Setup data dir. // Setup data dir.
EXPECT_TRUE(profile_temp_dir.CreateUniqueTempDir()); ASSERT_TRUE(profile_temp_dir.CreateUniqueTempDir());
ASSERT_EQ( ASSERT_EQ(
base::WriteFile(profile_temp_dir.GetPath().AppendASCII(kTestDataFileIn), base::WriteFile(profile_temp_dir.GetPath().AppendASCII(kTestDataFileIn),
nullptr, 0), nullptr, 0),
...@@ -559,3 +564,75 @@ TEST(ContextProviderImplParamsTest, WithInsecureOriginsAsSecure) { ...@@ -559,3 +564,75 @@ TEST(ContextProviderImplParamsTest, WithInsecureOriginsAsSecure) {
loop.Run(); loop.Run();
} }
TEST(ContextProviderImplConfigTest, WithDataQuotaBytes) {
const base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
base::RunLoop loop;
ContextProviderImpl context_provider;
context_provider.SetLaunchCallbackForTest(
base::BindLambdaForTesting([&loop](const base::CommandLine& command,
const base::LaunchOptions& options) {
EXPECT_EQ(command.GetSwitchValueASCII("data-quota-bytes"),
kTestQuotaBytesSwitchValue);
loop.Quit();
return base::Process();
}));
fuchsia::web::ContextPtr context;
context.set_error_handler([&loop](zx_status_t status) {
ZX_LOG(ERROR, status);
ADD_FAILURE();
loop.Quit();
});
fuchsia::web::CreateContextParams create_params = BuildCreateContextParams();
base::ScopedTempDir profile_temp_dir;
ASSERT_TRUE(profile_temp_dir.CreateUniqueTempDir());
create_params.set_data_directory(
base::OpenDirectoryHandle(profile_temp_dir.GetPath()));
create_params.set_data_quota_bytes(kTestQuotaBytes);
context_provider.Create(std::move(create_params), context.NewRequest());
loop.Run();
}
// TODO(crbug.com/1013412): This test doesn't actually exercise DRM, so could
// be executed everywhere if DRM support were configurable.
#if defined(ARCH_CPU_ARM64)
TEST(ContextProviderImplConfigTest, WithCdmDataQuotaBytes) {
const base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
base::RunLoop loop;
ContextProviderImpl context_provider;
context_provider.SetLaunchCallbackForTest(
base::BindLambdaForTesting([&loop](const base::CommandLine& command,
const base::LaunchOptions& options) {
EXPECT_EQ(command.GetSwitchValueASCII("cdm-data-quota-bytes"),
kTestQuotaBytesSwitchValue);
loop.Quit();
return base::Process();
}));
fuchsia::web::ContextPtr context;
context.set_error_handler([&loop](zx_status_t status) {
ZX_LOG(ERROR, status);
ADD_FAILURE();
loop.Quit();
});
fuchsia::web::CreateContextParams create_params = BuildCreateContextParams();
base::ScopedTempDir profile_temp_dir;
ASSERT_TRUE(profile_temp_dir.CreateUniqueTempDir());
create_params.set_cdm_data_directory(
base::OpenDirectoryHandle(profile_temp_dir.GetPath()));
create_params.set_features(fuchsia::web::ContextFeatureFlags::HEADLESS |
fuchsia::web::ContextFeatureFlags::WIDEVINE_CDM);
create_params.set_cdm_data_quota_bytes(kTestQuotaBytes);
context_provider.Create(std::move(create_params), context.NewRequest());
loop.Run();
}
#endif // defined(ARCH_CPU_ARM64)
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