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

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
« no previous file with comments | « mojo/shell/application_manager.mojom ('k') | mojo/shell/application_manager_apptest_target.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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",
90 filter.Pass());
85 // Put the other end on the command line used to launch the target. 91 // Put the other end on the command line used to launch the target.
86 platform_channel_pair.PrepareToPassClientHandleToChildProcess( 92 platform_channel_pair.PrepareToPassClientHandleToChildProcess(
87 &child_command_line, &handle_passing_info); 93 &child_command_line, &handle_passing_info);
88 94
89 base::LaunchOptions options; 95 base::LaunchOptions options;
90 #if defined(OS_WIN) 96 #if defined(OS_WIN)
91 options.handles_to_inherit = &handle_passing_info; 97 options.handles_to_inherit = &handle_passing_info;
92 #elif defined(OS_POSIX) 98 #elif defined(OS_POSIX)
93 options.fds_to_remap = &handle_passing_info; 99 options.fds_to_remap = &handle_passing_info;
94 #endif 100 #endif
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 132
127 int main(int argc, char** argv) { 133 int main(int argc, char** argv) {
128 base::AtExitManager at_exit; 134 base::AtExitManager at_exit;
129 base::CommandLine::Init(argc, argv); 135 base::CommandLine::Init(argc, argv);
130 136
131 mojo::runner::InitializeLogging(); 137 mojo::runner::InitializeLogging();
132 138
133 TargetApplicationDelegate delegate; 139 TargetApplicationDelegate delegate;
134 return mojo::runner::TestNativeMain(&delegate); 140 return mojo::runner::TestNativeMain(&delegate);
135 } 141 }
OLDNEW
« no previous file with comments | « mojo/shell/application_manager.mojom ('k') | mojo/shell/application_manager_apptest_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698