forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow mojo_runner to connect to arbitrary executables.
- Introduces a new scheme "exe" which loads an executable alongside mojo_runner. TODO is some more security checking around this to prevent arbitrary apps from launching executables but since this is implemented in mojo_runner it's not in any production code right now. - Includes an apptest of a .mojo app that connects to an executable and binds a service provided by it. - Creates a new child library that makes it easy to bring up a runner controller thread in an arbitrary executable. R=jam@chromium.org http://crbug.com/548694 Review URL: https://codereview.chromium.org/1419293003 Cr-Commit-Position: refs/heads/master@{#357034}
- Loading branch information
ben
authored and
Commit bot
committed
Oct 30, 2015
1 parent
1c31871
commit 48799d7
Showing
20 changed files
with
625 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Copyright 2015 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//mojo/public/mojo_application.gni") | ||
import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") | ||
|
||
group("child") { | ||
testonly = true | ||
deps = [ | ||
":lib", | ||
":apptests", | ||
] | ||
} | ||
|
||
source_set("lib") { | ||
sources = [ | ||
"runner_connection.cc", | ||
"runner_connection.h", | ||
] | ||
|
||
deps = [ | ||
":interfaces", | ||
"//base", | ||
"//mojo/application/public/interfaces", | ||
"//mojo/message_pump", | ||
"//third_party/mojo/src/mojo/edk/system", | ||
] | ||
} | ||
|
||
mojom("interfaces") { | ||
sources = [ | ||
"child_controller.mojom", | ||
] | ||
|
||
deps = [ | ||
"//mojo/application/public/interfaces", | ||
] | ||
|
||
import_dirs = [ "//mojo/services" ] | ||
} | ||
|
||
mojom("apptest_interfaces") { | ||
sources = [ | ||
"test_native_service.mojom", | ||
] | ||
|
||
deps = [ | ||
"//mojo/application/public/interfaces", | ||
] | ||
|
||
import_dirs = [ "//mojo/services" ] | ||
} | ||
|
||
mojo_native_application("apptests") { | ||
output_name = "mojo_runner_child_apptest" | ||
testonly = true | ||
|
||
sources = [ | ||
"native_apptest.cc", | ||
] | ||
|
||
deps = [ | ||
":apptest_interfaces", | ||
"//base", | ||
"//base/test:test_config", | ||
"//mojo/application/public/cpp:sources", | ||
"//mojo/application/public/cpp:test_support", | ||
"//mojo/common:common_base", | ||
"//mojo/converters/network:network", | ||
] | ||
|
||
data_deps = [ | ||
":native_target", | ||
] | ||
} | ||
|
||
executable("native_target") { | ||
output_name = "mojo_runner_child_apptest_native_target" | ||
testonly = true | ||
|
||
sources = [ | ||
"native_apptest_target.cc", | ||
] | ||
|
||
deps = [ | ||
":apptest_interfaces", | ||
":lib", | ||
"//base", | ||
"//mojo/application/public/cpp", | ||
"//mojo/application/public/interfaces", | ||
"//mojo/common:common_base", | ||
"//mojo/message_pump", | ||
"//mojo/runner:init", | ||
"//third_party/mojo/src/mojo/edk/embedder:embedder", | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/bind.h" | ||
#include "base/macros.h" | ||
#include "mojo/application/public/cpp/application_impl.h" | ||
#include "mojo/application/public/cpp/application_test_base.h" | ||
#include "mojo/converters/network/network_type_converters.h" | ||
#include "mojo/runner/child/test_native_service.mojom.h" | ||
|
||
namespace mojo { | ||
namespace runner { | ||
namespace { | ||
void InvertCallback(bool* result, bool from_native) { | ||
*result = from_native; | ||
} | ||
} // namespace | ||
|
||
using NativeAppTest = mojo::test::ApplicationTestBase; | ||
|
||
TEST_F(NativeAppTest, Connect) { | ||
test::TestNativeServicePtr native_service; | ||
application_impl()->ConnectToService( | ||
mojo::URLRequest::From( | ||
std::string("exe:mojo_runner_child_apptest_native_target")), | ||
&native_service); | ||
|
||
bool result = false; | ||
native_service->Invert( | ||
true, base::Bind(&InvertCallback, base::Unretained(&result))); | ||
native_service.WaitForIncomingResponse(); | ||
EXPECT_FALSE(result); | ||
|
||
native_service->Invert( | ||
false, base::Bind(&InvertCallback, base::Unretained(&result))); | ||
native_service.WaitForIncomingResponse(); | ||
EXPECT_TRUE(result); | ||
} | ||
|
||
} // namespace runner | ||
} // namespace mojo |
Oops, something went wrong.