Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Unified Diff: content/public/browser/utility_process_mojo_client.h

Issue 2697463002: Convert utility process extension Unpacker IPC to mojo (Closed)
Patch Set: Sync to ToT. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/browser/utility_process_mojo_client.h
diff --git a/content/public/browser/utility_process_mojo_client.h b/content/public/browser/utility_process_mojo_client.h
index cfcb93b953dd1b87f3c8dc4dba6722809db9ac8b..35ff7fe516b7ffd172ac001dee2c3d6c780329b5 100644
--- a/content/public/browser/utility_process_mojo_client.h
+++ b/content/public/browser/utility_process_mojo_client.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/callback.h"
+#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string16.h"
@@ -38,8 +39,15 @@ class UtilityProcessMojoClient {
// Sets the error callback. A valid callback must be set before calling
// Start().
- void set_error_callback(const base::Closure& on_error_callback) {
- on_error_callback_ = on_error_callback;
+ void set_error_callback(const base::Closure& error_callback) {
+ error_callback_ = error_callback;
+ }
+
+ // Allows a directory to be opened through the utility process sandbox.
+ void set_exposed_directory(const base::FilePath& directory) {
+ DCHECK(!start_called_);
+ DCHECK(!directory.empty());
+ helper_->set_exposed_directory(directory);
}
// Disables the sandbox in the utility process.
@@ -49,24 +57,24 @@ class UtilityProcessMojoClient {
}
#if defined(OS_WIN)
- // Allow the utility process to run with elevated privileges.
+ // Allows the utility process to run with elevated privileges.
void set_run_elevated() {
DCHECK(!start_called_);
helper_->set_run_elevated();
}
#endif // defined(OS_WIN)
- // Starts the utility process and connect to the remote Mojo service.
+ // Starts the utility process and connects to the remote Mojo service.
void Start() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!on_error_callback_.is_null());
+ DCHECK(error_callback_);
DCHECK(!start_called_);
start_called_ = true;
- mojo::InterfaceRequest<MojoInterface> req(&service_);
- service_.set_connection_error_handler(on_error_callback_);
- helper_->Start(MojoInterface::Name_, req.PassMessagePipe());
+ mojo::InterfaceRequest<MojoInterface> request(&service_);
+ service_.set_connection_error_handler(error_callback_);
+ helper_->Start(MojoInterface::Name_, request.PassMessagePipe());
}
// Returns the Mojo service used to make calls to the utility process.
@@ -102,6 +110,10 @@ class UtilityProcessMojoClient {
mojo_interface_name, base::Passed(&interface_pipe)));
}
+ void set_exposed_directory(const base::FilePath& directory) {
+ exposed_directory_ = directory;
+ }
+
void set_disable_sandbox() { disable_sandbox_ = true; }
#if defined(OS_WIN)
@@ -120,6 +132,9 @@ class UtilityProcessMojoClient {
utility_host_ = UtilityProcessHost::Create(nullptr, nullptr)->AsWeakPtr();
utility_host_->SetName(process_name_);
+ if (!exposed_directory_.empty())
+ utility_host_->SetExposedDir(exposed_directory_);
+
if (disable_sandbox_)
utility_host_->DisableSandbox();
#if defined(OS_WIN)
@@ -137,6 +152,7 @@ class UtilityProcessMojoClient {
// Properties of the utility process.
base::string16 process_name_;
+ base::FilePath exposed_directory_;
bool disable_sandbox_ = false;
#if defined(OS_WIN)
bool run_elevated_ = false;
@@ -151,7 +167,7 @@ class UtilityProcessMojoClient {
std::unique_ptr<Helper> helper_;
// Called when a connection error happens or if the process didn't start.
- base::Closure on_error_callback_;
+ base::Closure error_callback_;
mojo::InterfacePtr<MojoInterface> service_;

Powered by Google App Engine
This is Rietveld 408576698