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

Side by Side Diff: services/service_manager/runner/common/client_util.cc

Issue 2680973006: Mojo EDK: Add safe process connection API (Closed)
Patch Set: . Created 3 years, 10 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/service_manager/runner/common/client_util.h" 5 #include "services/service_manager/runner/common/client_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "mojo/edk/embedder/embedder.h" 10 #include "mojo/edk/embedder/embedder.h"
11 #include "mojo/edk/embedder/pending_process_connection.h"
11 #include "services/service_manager/runner/common/switches.h" 12 #include "services/service_manager/runner/common/switches.h"
12 13
13 namespace service_manager { 14 namespace service_manager {
14 15
15 mojom::ServicePtr PassServiceRequestOnCommandLine( 16 mojom::ServicePtr PassServiceRequestOnCommandLine(
16 base::CommandLine* command_line, const std::string& child_token) { 17 mojo::edk::PendingProcessConnection* connection,
17 std::string token = mojo::edk::GenerateRandomToken(); 18 base::CommandLine* command_line) {
19 std::string token;
20 mojom::ServicePtr client;
21 client.Bind(mojom::ServicePtrInfo(connection->CreateMessagePipe(&token), 0));
18 command_line->AppendSwitchASCII(switches::kPrimordialPipeToken, token); 22 command_line->AppendSwitchASCII(switches::kPrimordialPipeToken, token);
19
20 mojom::ServicePtr client;
21 client.Bind(
22 mojom::ServicePtrInfo(
23 mojo::edk::CreateParentMessagePipe(token, child_token), 0));
24 return client; 23 return client;
25 } 24 }
26 25
27 mojom::ServiceRequest GetServiceRequestFromCommandLine() { 26 mojom::ServiceRequest GetServiceRequestFromCommandLine() {
28 std::string token = 27 std::string token =
29 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 28 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
30 switches::kPrimordialPipeToken); 29 switches::kPrimordialPipeToken);
31 mojom::ServiceRequest request; 30 mojom::ServiceRequest request;
32 if (!token.empty()) 31 if (!token.empty())
33 request.Bind(mojo::edk::CreateChildMessagePipe(token)); 32 request.Bind(mojo::edk::CreateChildMessagePipe(token));
34 return request; 33 return request;
35 } 34 }
36 35
37 bool ServiceManagerIsRemote() { 36 bool ServiceManagerIsRemote() {
38 return base::CommandLine::ForCurrentProcess()->HasSwitch( 37 return base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kPrimordialPipeToken); 38 switches::kPrimordialPipeToken);
40 } 39 }
41 40
42 } // namespace service_manager 41 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/runner/common/client_util.h ('k') | services/service_manager/runner/host/service_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698