[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: David Dorwin <ddorwin@chromium.org> Cr-Commit-Position: refs/heads/master@{#833805}
This commit is contained in:
@ -265,6 +265,8 @@ void ContextProviderImpl::Create(
|
||||
launch_options.handles_to_transfer.push_back(
|
||||
{kContextRequestHandleId, context_request.channel().get()});
|
||||
|
||||
base::CommandLine launch_command(*base::CommandLine::ForCurrentProcess());
|
||||
|
||||
// Bind |data_directory| to /data directory, if provided.
|
||||
zx::channel data_directory_channel;
|
||||
if (params.has_data_directory()) {
|
||||
@ -285,10 +287,13 @@ void ContextProviderImpl::Create(
|
||||
}
|
||||
launch_options.paths_to_transfer.push_back(
|
||||
base::PathToTransfer{data_path, data_directory_channel.release()});
|
||||
}
|
||||
|
||||
base::CommandLine launch_command = *base::CommandLine::ForCurrentProcess();
|
||||
std::vector<zx::channel> devtools_listener_channels;
|
||||
if (params.has_data_quota_bytes()) {
|
||||
launch_command.AppendSwitchNative(
|
||||
switches::kDataQuotaBytes,
|
||||
base::NumberToString(params.data_quota_bytes()));
|
||||
}
|
||||
}
|
||||
|
||||
// Process command-line settings specified in our package config-data.
|
||||
base::Value web_engine_config;
|
||||
@ -310,6 +315,7 @@ void ContextProviderImpl::Create(
|
||||
base::NumberToString(params.remote_debugging_port()));
|
||||
}
|
||||
|
||||
std::vector<zx::channel> devtools_listener_channels;
|
||||
if (devtools_listeners_.size() != 0) {
|
||||
// Connect DevTools listeners to the new Context process.
|
||||
std::vector<std::string> handles_ids;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "base/test/multiprocess_test.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "base/test/test_timeouts.h"
|
||||
#include "build/build_config.h"
|
||||
#include "fuchsia/engine/context_provider_impl.h"
|
||||
#include "fuchsia/engine/fake_context.h"
|
||||
#include "fuchsia/engine/switches.h"
|
||||
@ -45,9 +46,13 @@ namespace {
|
||||
|
||||
constexpr char kTestDataFileIn[] = "DataFileIn";
|
||||
constexpr char kTestDataFileOut[] = "DataFileOut";
|
||||
|
||||
constexpr char kUrl[] = "chrome://:emorhc";
|
||||
constexpr char kTitle[] = "Palindrome";
|
||||
|
||||
constexpr uint64_t kTestQuotaBytes = 1024;
|
||||
constexpr char kTestQuotaBytesSwitchValue[] = "1024";
|
||||
|
||||
MULTIPROCESS_TEST_MAIN(SpawnContextServer) {
|
||||
base::test::SingleThreadTaskEnvironment task_environment(
|
||||
base::test::SingleThreadTaskEnvironment::MainThreadType::IO);
|
||||
@ -344,7 +349,7 @@ TEST_F(ContextProviderImplTest, WithProfileDir) {
|
||||
fuchsia::web::CreateContextParams create_params = BuildCreateContextParams();
|
||||
|
||||
// Setup data dir.
|
||||
EXPECT_TRUE(profile_temp_dir.CreateUniqueTempDir());
|
||||
ASSERT_TRUE(profile_temp_dir.CreateUniqueTempDir());
|
||||
ASSERT_EQ(
|
||||
base::WriteFile(profile_temp_dir.GetPath().AppendASCII(kTestDataFileIn),
|
||||
nullptr, 0),
|
||||
@ -559,3 +564,75 @@ TEST(ContextProviderImplParamsTest, WithInsecureOriginsAsSecure) {
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user