Commit 42b4e9ec authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[fuchsia] Fix deletion threading for sandbox policy's ServiceDirectory.

SandboxPolicyFuchsia is not thread affine but its ServiceDirectory
is not. This CL schedules the ServiceDirectory's deletion on the
same thread that was used for its construction.

Change-Id: I98e950481e49106ba64c759cef2c903b5dcf5d3b
Reviewed-on: https://chromium-review.googlesource.com/1171673Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582457}
parent 218f17e7
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/fuchsia/filtered_service_directory.h" #include "base/fuchsia/filtered_service_directory.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/process/process.h" #include "base/process/process.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "services/service_manager/sandbox/switches.h" #include "services/service_manager/sandbox/switches.h"
...@@ -25,7 +26,11 @@ constexpr const char* const kRendererServices[] = { ...@@ -25,7 +26,11 @@ constexpr const char* const kRendererServices[] = {
fuchsia::fonts::FontProvider::Name_}; fuchsia::fonts::FontProvider::Name_};
SandboxPolicyFuchsia::SandboxPolicyFuchsia() = default; SandboxPolicyFuchsia::SandboxPolicyFuchsia() = default;
SandboxPolicyFuchsia::~SandboxPolicyFuchsia() = default;
SandboxPolicyFuchsia::~SandboxPolicyFuchsia() {
service_directory_task_runner_->DeleteSoon(FROM_HERE,
std::move(service_directory_));
}
void SandboxPolicyFuchsia::Initialize(service_manager::SandboxType type) { void SandboxPolicyFuchsia::Initialize(service_manager::SandboxType type) {
DCHECK_NE(type, service_manager::SANDBOX_TYPE_INVALID); DCHECK_NE(type, service_manager::SANDBOX_TYPE_INVALID);
...@@ -39,6 +44,7 @@ void SandboxPolicyFuchsia::Initialize(service_manager::SandboxType type) { ...@@ -39,6 +44,7 @@ void SandboxPolicyFuchsia::Initialize(service_manager::SandboxType type) {
} }
if (type_ == service_manager::SANDBOX_TYPE_RENDERER) { if (type_ == service_manager::SANDBOX_TYPE_RENDERER) {
service_directory_task_runner_ = base::ThreadTaskRunnerHandle::Get();
// Create FilteredServicesDirectory for the renderer process and export all // Create FilteredServicesDirectory for the renderer process and export all
// services in kRendererServices. ServiceDirectoryProxy must be initialized // services in kRendererServices. ServiceDirectoryProxy must be initialized
// on a thread that has async_dispatcher. // on a thread that has async_dispatcher.
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
#ifndef CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_ #ifndef CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_
#define CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_ #define CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_
#include "base/memory/ref_counted.h"
#include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/sandbox_type.h"
namespace base { namespace base {
struct LaunchOptions; struct LaunchOptions;
class SequencedTaskRunner;
namespace fuchsia { namespace fuchsia {
class FilteredServiceDirectory; class FilteredServiceDirectory;
...@@ -38,6 +40,7 @@ class SandboxPolicyFuchsia { ...@@ -38,6 +40,7 @@ class SandboxPolicyFuchsia {
// Services directory used for the /svc namespace of the child process. // Services directory used for the /svc namespace of the child process.
std::unique_ptr<base::fuchsia::FilteredServiceDirectory> service_directory_; std::unique_ptr<base::fuchsia::FilteredServiceDirectory> service_directory_;
scoped_refptr<base::SequencedTaskRunner> service_directory_task_runner_;
}; };
} // namespace content } // namespace content
......
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