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

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

Issue 1538823002: Convert Pass()→std::move() in mojo/ (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_apptest.cc ('k') | mojo/shell/application_manager_unittest.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 <utility>
6
5 #include "base/at_exit.h" 7 #include "base/at_exit.h"
6 #include "base/base_paths.h" 8 #include "base/base_paths.h"
7 #include "base/base_switches.h" 9 #include "base/base_switches.h"
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/command_line.h" 11 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h" 15 #include "base/path_service.h"
14 #include "base/process/process.h" 16 #include "base/process/process.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 mojo::embedder::HandlePassingInformation handle_passing_info; 72 mojo::embedder::HandlePassingInformation handle_passing_info;
71 73
72 // Create the channel to be shared with the target process. 74 // Create the channel to be shared with the target process.
73 mojo::embedder::PlatformChannelPair platform_channel_pair; 75 mojo::embedder::PlatformChannelPair platform_channel_pair;
74 // Give one end to the shell so that it can create an instance. 76 // Give one end to the shell so that it can create an instance.
75 mojo::embedder::ScopedPlatformHandle platform_channel = 77 mojo::embedder::ScopedPlatformHandle platform_channel =
76 platform_channel_pair.PassServerHandle(); 78 platform_channel_pair.PassServerHandle();
77 79
78 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel( 80 mojo::ScopedMessagePipeHandle handle(mojo::embedder::CreateChannel(
79 platform_channel.Pass(), 81 std::move(platform_channel),
80 base::Bind(&TargetApplicationDelegate::DidCreateChannel, 82 base::Bind(&TargetApplicationDelegate::DidCreateChannel,
81 weak_factory_.GetWeakPtr()), 83 weak_factory_.GetWeakPtr()),
82 base::ThreadTaskRunnerHandle::Get())); 84 base::ThreadTaskRunnerHandle::Get()));
83 85
84 // The platform handle used for the new EDK's broker. 86 // The platform handle used for the new EDK's broker.
85 mojo::edk::PlatformChannelPair broker_channel_pair; 87 mojo::edk::PlatformChannelPair broker_channel_pair;
86 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { 88 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) {
87 std::string client_handle_as_string = 89 std::string client_handle_as_string =
88 broker_channel_pair.PrepareToPassClientHandleToChildProcessAsString( 90 broker_channel_pair.PrepareToPassClientHandleToChildProcessAsString(
89 &handle_passing_info); 91 &handle_passing_info);
90 MojoResult rv = MojoWriteMessage( 92 MojoResult rv = MojoWriteMessage(
91 handle.get().value(), client_handle_as_string.c_str(), 93 handle.get().value(), client_handle_as_string.c_str(),
92 static_cast<uint32_t>(client_handle_as_string.size()), nullptr, 0, 94 static_cast<uint32_t>(client_handle_as_string.size()), nullptr, 0,
93 MOJO_WRITE_MESSAGE_FLAG_NONE); 95 MOJO_WRITE_MESSAGE_FLAG_NONE);
94 DCHECK_EQ(rv, MOJO_RESULT_OK); 96 DCHECK_EQ(rv, MOJO_RESULT_OK);
95 } 97 }
96 98
97 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New()); 99 mojo::CapabilityFilterPtr filter(mojo::CapabilityFilter::New());
98 mojo::Array<mojo::String> test_interfaces; 100 mojo::Array<mojo::String> test_interfaces;
99 test_interfaces.push_back( 101 test_interfaces.push_back(
100 mojo::shell::test::mojom::CreateInstanceForHandleTest::Name_); 102 mojo::shell::test::mojom::CreateInstanceForHandleTest::Name_);
101 filter->filter.insert("mojo:mojo_shell_apptests", test_interfaces.Pass()); 103 filter->filter.insert("mojo:mojo_shell_apptests",
104 std::move(test_interfaces));
102 application_manager->CreateInstanceForHandle( 105 application_manager->CreateInstanceForHandle(
103 mojo::ScopedHandle(mojo::Handle(handle.release().value())), 106 mojo::ScopedHandle(mojo::Handle(handle.release().value())),
104 "exe:application_manager_apptest_target", 107 "exe:application_manager_apptest_target", std::move(filter));
105 filter.Pass());
106 // Put the other end on the command line used to launch the target. 108 // Put the other end on the command line used to launch the target.
107 platform_channel_pair.PrepareToPassClientHandleToChildProcess( 109 platform_channel_pair.PrepareToPassClientHandleToChildProcess(
108 &child_command_line, &handle_passing_info); 110 &child_command_line, &handle_passing_info);
109 111
110 base::LaunchOptions options; 112 base::LaunchOptions options;
111 #if defined(OS_WIN) 113 #if defined(OS_WIN)
112 options.handles_to_inherit = &handle_passing_info; 114 options.handles_to_inherit = &handle_passing_info;
113 #elif defined(OS_POSIX) 115 #elif defined(OS_POSIX)
114 options.fds_to_remap = &handle_passing_info; 116 options.fds_to_remap = &handle_passing_info;
115 #endif 117 #endif
(...skipping 11 matching lines...) Expand all
127 } 129 }
128 bool ConfigureIncomingConnection( 130 bool ConfigureIncomingConnection(
129 mojo::ApplicationConnection* connection) override { 131 mojo::ApplicationConnection* connection) override {
130 connection->AddService<Driver>(this); 132 connection->AddService<Driver>(this);
131 return true; 133 return true;
132 } 134 }
133 135
134 // mojo::InterfaceFactory<Driver>: 136 // mojo::InterfaceFactory<Driver>:
135 void Create(mojo::ApplicationConnection* connection, 137 void Create(mojo::ApplicationConnection* connection,
136 mojo::InterfaceRequest<Driver> request) override { 138 mojo::InterfaceRequest<Driver> request) override {
137 bindings_.AddBinding(this, request.Pass()); 139 bindings_.AddBinding(this, std::move(request));
138 } 140 }
139 141
140 // Driver: 142 // Driver:
141 void QuitDriver() override { 143 void QuitDriver() override {
142 target_.Terminate(0, false); 144 target_.Terminate(0, false);
143 app_->Quit(); 145 app_->Quit();
144 } 146 }
145 147
146 void DidCreateChannel(mojo::embedder::ChannelInfo* channel_info) {} 148 void DidCreateChannel(mojo::embedder::ChannelInfo* channel_info) {}
147 149
148 mojo::ApplicationImpl* app_; 150 mojo::ApplicationImpl* app_;
149 base::Process target_; 151 base::Process target_;
150 mojo::WeakBindingSet<Driver> bindings_; 152 mojo::WeakBindingSet<Driver> bindings_;
151 base::WeakPtrFactory<TargetApplicationDelegate> weak_factory_; 153 base::WeakPtrFactory<TargetApplicationDelegate> weak_factory_;
152 154
153 DISALLOW_COPY_AND_ASSIGN(TargetApplicationDelegate); 155 DISALLOW_COPY_AND_ASSIGN(TargetApplicationDelegate);
154 }; 156 };
155 157
156 } // namespace 158 } // namespace
157 159
158 int main(int argc, char** argv) { 160 int main(int argc, char** argv) {
159 base::AtExitManager at_exit; 161 base::AtExitManager at_exit;
160 base::CommandLine::Init(argc, argv); 162 base::CommandLine::Init(argc, argv);
161 163
162 mojo::runner::InitializeLogging(); 164 mojo::runner::InitializeLogging();
163 165
164 TargetApplicationDelegate delegate; 166 TargetApplicationDelegate delegate;
165 return mojo::runner::TestNativeMain(&delegate); 167 return mojo::runner::TestNativeMain(&delegate);
166 } 168 }
OLDNEW
« no previous file with comments | « mojo/shell/application_manager_apptest.cc ('k') | mojo/shell/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698