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

Side by Side Diff: mojo/shell/application_manager_apptest_driver.cc

Issue 1465793005: Pass CapabilityFilter via CreateInstanceForHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/base_paths.h" 6 #include "base/base_paths.h"
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "mojo/application/public/cpp/application_connection.h" 16 #include "mojo/application/public/cpp/application_connection.h"
17 #include "mojo/application/public/cpp/application_delegate.h" 17 #include "mojo/application/public/cpp/application_delegate.h"
18 #include "mojo/application/public/cpp/application_impl.h" 18 #include "mojo/application/public/cpp/application_impl.h"
19 #include "mojo/application/public/cpp/interface_factory.h" 19 #include "mojo/application/public/cpp/interface_factory.h"
20 #include "mojo/application/public/interfaces/application_manager.mojom.h"
20 #include "mojo/common/weak_binding_set.h" 21 #include "mojo/common/weak_binding_set.h"
21 #include "mojo/converters/network/network_type_converters.h" 22 #include "mojo/converters/network/network_type_converters.h"
22 #include "mojo/runner/child/test_native_main.h" 23 #include "mojo/runner/child/test_native_main.h"
23 #include "mojo/runner/init.h" 24 #include "mojo/runner/init.h"
24 #include "mojo/shell/application_manager.mojom.h"
25 #include "mojo/shell/application_manager_apptests.mojom.h" 25 #include "mojo/shell/application_manager_apptests.mojom.h"
26 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" 26 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
27 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" 27 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h"
28 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" 28 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
29 29
30 using mojo::shell::test::mojom::Driver; 30 using mojo::shell::test::mojom::Driver;
31 31
32 namespace { 32 namespace {
33 33
34 class TargetApplicationDelegate : public mojo::ApplicationDelegate, 34 class TargetApplicationDelegate : public mojo::ApplicationDelegate,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Give one end to the shell so that it can create an instance. 72 // Give one end to the shell so that it can create an instance.
73 mojo::embedder::ScopedPlatformHandle platform_channel = 73 mojo::embedder::ScopedPlatformHandle platform_channel =
74 platform_channel_pair.PassServerHandle(); 74 platform_channel_pair.PassServerHandle();
75 75
76 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel( 76 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel(
77 platform_channel.Pass(), 77 platform_channel.Pass(),
78 base::Bind(&TargetApplicationDelegate::DidCreateChannel, 78 base::Bind(&TargetApplicationDelegate::DidCreateChannel,
79 weak_factory_.GetWeakPtr()), 79 weak_factory_.GetWeakPtr()),
80 base::ThreadTaskRunnerHandle::Get())); 80 base::ThreadTaskRunnerHandle::Get()));
81 81
82 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New());
83 mojo::Array<mojo::String> test_interfaces;
84 test_interfaces.push_back(
85 mojo::shell::test::mojom::CreateInstanceForHandleTest::Name_);
86 filter->filter.insert("mojo:mojo_shell_apptests", test_interfaces.Pass());
82 application_manager->CreateInstanceForHandle( 87 application_manager->CreateInstanceForHandle(
83 mojo::ScopedHandle(mojo::Handle(handle.release().value())), 88 mojo::ScopedHandle(mojo::Handle(handle.release().value())),
84 "exe:application_manager_apptest_target", 89 "exe:application_manager_apptest_target",
85 "0"); 90 filter.Pass());
91
86 // Put the other end on the command line used to launch the target. 92 // Put the other end on the command line used to launch the target.
87 platform_channel_pair.PrepareToPassClientHandleToChildProcess( 93 platform_channel_pair.PrepareToPassClientHandleToChildProcess(
88 &child_command_line, &handle_passing_info); 94 &child_command_line, &handle_passing_info);
89 95
90 base::LaunchOptions options; 96 base::LaunchOptions options;
91 #if defined(OS_WIN) 97 #if defined(OS_WIN)
92 options.handles_to_inherit = &handle_passing_info; 98 options.handles_to_inherit = &handle_passing_info;
93 #elif defined(OS_POSIX) 99 #elif defined(OS_POSIX)
94 options.fds_to_remap = &handle_passing_info; 100 options.fds_to_remap = &handle_passing_info;
95 #endif 101 #endif
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 133
128 int main(int argc, char** argv) { 134 int main(int argc, char** argv) {
129 base::AtExitManager at_exit; 135 base::AtExitManager at_exit;
130 base::CommandLine::Init(argc, argv); 136 base::CommandLine::Init(argc, argv);
131 137
132 mojo::runner::InitializeLogging(); 138 mojo::runner::InitializeLogging();
133 139
134 TargetApplicationDelegate delegate; 140 TargetApplicationDelegate delegate;
135 return mojo::runner::TestNativeMain(&delegate); 141 return mojo::runner::TestNativeMain(&delegate);
136 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698