summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
Diffstat (limited to 'mojo')
-rw-r--r--mojo/shell/background/background_shell.cc26
-rw-r--r--mojo/shell/background/background_shell.h8
-rw-r--r--mojo/shell/background/tests/test_catalog_store.cc16
-rw-r--r--mojo/shell/standalone/context.cc6
-rw-r--r--mojo/shell/standalone/context.h2
5 files changed, 45 insertions, 13 deletions
diff --git a/mojo/shell/background/background_shell.cc b/mojo/shell/background/background_shell.cc
index ed1d5c5..a21bbe4 100644
--- a/mojo/shell/background/background_shell.cc
+++ b/mojo/shell/background/background_shell.cc
@@ -102,6 +102,11 @@ class BackgroundShell::MojoThread : public base::SimpleThread {
Join();
}
+ void RunShellCallback(const BackgroundShell::ShellThreadCallback& callback) {
+ DCHECK_EQ(message_loop_, base::MessageLoop::current());
+ callback.Run(context_->shell());
+ }
+
// base::SimpleThread:
void Start() override {
DCHECK(!message_loop_);
@@ -113,12 +118,6 @@ class BackgroundShell::MojoThread : public base::SimpleThread {
// in the order here.
scoped_ptr<base::MessageLoop> message_loop(message_loop_);
- Context::EnsureEmbedderIsInitialized();
-
- message_loop_->BindToCurrentThread();
-
- scoped_ptr<Context> context(new Context);
- context_ = context.get();
scoped_ptr<mojo::shell::Context::InitParams> context_init_params(
new mojo::shell::Context::InitParams);
if (init_params_) {
@@ -126,7 +125,15 @@ class BackgroundShell::MojoThread : public base::SimpleThread {
std::move(init_params_->catalog_store);
context_init_params->native_runner_delegate =
init_params_->native_runner_delegate;
+ context_init_params->init_edk = init_params_->init_edk;
}
+ if (context_init_params->init_edk)
+ Context::EnsureEmbedderIsInitialized();
+
+ message_loop_->BindToCurrentThread();
+
+ scoped_ptr<Context> context(new Context);
+ context_ = context.get();
context_->Init(std::move(context_init_params));
message_loop_->Run();
@@ -191,5 +198,12 @@ mojom::ShellClientRequest BackgroundShell::CreateShellClientRequest(
return request;
}
+void BackgroundShell::ExecuteOnShellThread(
+ const ShellThreadCallback& callback) {
+ thread_->message_loop()->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&MojoThread::RunShellCallback,
+ base::Unretained(thread_.get()), callback));
+}
+
} // namespace shell
} // namespace mojo
diff --git a/mojo/shell/background/background_shell.h b/mojo/shell/background/background_shell.h
index 7af3714..070b5b1 100644
--- a/mojo/shell/background/background_shell.h
+++ b/mojo/shell/background/background_shell.h
@@ -21,6 +21,7 @@ namespace mojo {
namespace shell {
class NativeRunnerDelegate;
+class Shell;
// BackgroundShell starts up the mojo shell on a background thread, and
// destroys the thread in the destructor. Once created use CreateApplication()
@@ -34,6 +35,8 @@ class BackgroundShell {
NativeRunnerDelegate* native_runner_delegate = nullptr;
scoped_ptr<catalog::Store> catalog_store;
+ // If true the edk is initialized.
+ bool init_edk = true;
};
BackgroundShell();
@@ -47,6 +50,11 @@ class BackgroundShell {
mojom::ShellClientRequest CreateShellClientRequest(
const std::string& name);
+ // Use to do processing on the thread running the shell. The callback is
+ // supplied a pointer to the Shell. The callback does *not* own the Shell.
+ using ShellThreadCallback = base::Callback<void(Shell*)>;
+ void ExecuteOnShellThread(const ShellThreadCallback& callback);
+
private:
class MojoThread;
diff --git a/mojo/shell/background/tests/test_catalog_store.cc b/mojo/shell/background/tests/test_catalog_store.cc
index 32a1aa4..41daf82 100644
--- a/mojo/shell/background/tests/test_catalog_store.cc
+++ b/mojo/shell/background/tests/test_catalog_store.cc
@@ -28,14 +28,20 @@ scoped_ptr<base::DictionaryValue> BuildPermissiveSerializedAppInfo(
scoped_ptr<base::DictionaryValue> app(new base::DictionaryValue);
app->SetString(Store::kNameKey, name);
app->SetString(Store::kDisplayNameKey, display_name);
+ app->SetInteger(Store::kManifestVersionKey, 1);
scoped_ptr<base::DictionaryValue> capabilities(new base::DictionaryValue);
- scoped_ptr<base::ListValue> interfaces(new base::ListValue);
- interfaces->AppendString("*");
- capabilities->Set("*", std::move(interfaces));
-
+ scoped_ptr<base::DictionaryValue> required_capabilities(
+ new base::DictionaryValue);
+ scoped_ptr<base::DictionaryValue> interfaces_dictionary(
+ new base::DictionaryValue);
+ scoped_ptr<base::ListValue> interfaces_list(new base::ListValue);
+ interfaces_list->AppendString("*");
+ interfaces_dictionary->Set("interfaces", std::move(interfaces_list));
+ required_capabilities->Set("*", std::move(interfaces_dictionary));
+ capabilities->Set(Store::kCapabilities_RequiredKey,
+ std::move(required_capabilities));
app->Set(Store::kCapabilitiesKey, std::move(capabilities));
-
return app;
}
diff --git a/mojo/shell/standalone/context.cc b/mojo/shell/standalone/context.cc
index dc0a25b..5b53879 100644
--- a/mojo/shell/standalone/context.cc
+++ b/mojo/shell/standalone/context.cc
@@ -129,13 +129,15 @@ void Context::Init(scoped_ptr<InitParams> init_params) {
"mojo_runner.trace");
}
- EnsureEmbedderIsInitialized();
+ if (!init_params || init_params->init_edk)
+ EnsureEmbedderIsInitialized();
shell_runner_ = base::MessageLoop::current()->task_runner();
blocking_pool_ =
new base::SequencedWorkerPool(kMaxBlockingPoolThreads, "blocking_pool");
- edk::InitIPCSupport(this, io_thread_->task_runner().get());
+ if (!init_params || init_params->init_edk)
+ edk::InitIPCSupport(this, io_thread_->task_runner().get());
scoped_ptr<NativeRunnerFactory> runner_factory;
if (command_line.HasSwitch(switches::kSingleProcess)) {
diff --git a/mojo/shell/standalone/context.h b/mojo/shell/standalone/context.h
index 09f7942..3c25027 100644
--- a/mojo/shell/standalone/context.h
+++ b/mojo/shell/standalone/context.h
@@ -37,6 +37,8 @@ class Context : public edk::ProcessDelegate {
NativeRunnerDelegate* native_runner_delegate = nullptr;
scoped_ptr<catalog::Store> catalog_store;
+ // If true the edk is initialized.
+ bool init_edk = true;
};
Context();