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

Side by Side Diff: mojo/embedder/platform_channel_pair_win.cc

Issue 292743017: Cleanup: Use base::CommandLine in mojo/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/embedder/platform_channel_pair_posix.cc ('k') | mojo/examples/aura_demo/aura_demo.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/embedder/platform_channel_pair.h" 5 #include "mojo/embedder/platform_channel_pair.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 PCHECK(client_handle_.is_valid()); 66 PCHECK(client_handle_.is_valid());
67 67
68 // Since a client has connected, ConnectNamedPipe() should return zero and 68 // Since a client has connected, ConnectNamedPipe() should return zero and
69 // GetLastError() should return ERROR_PIPE_CONNECTED. 69 // GetLastError() should return ERROR_PIPE_CONNECTED.
70 CHECK(!ConnectNamedPipe(server_handle_.get().handle, NULL)); 70 CHECK(!ConnectNamedPipe(server_handle_.get().handle, NULL));
71 PCHECK(GetLastError() == ERROR_PIPE_CONNECTED); 71 PCHECK(GetLastError() == ERROR_PIPE_CONNECTED);
72 } 72 }
73 73
74 // static 74 // static
75 ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess( 75 ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
76 const CommandLine& command_line) { 76 const base::CommandLine& command_line) {
77 std::string client_handle_string = 77 std::string client_handle_string =
78 command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch); 78 command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch);
79 79
80 int client_handle_value = 0; 80 int client_handle_value = 0;
81 if (client_handle_string.empty() || 81 if (client_handle_string.empty() ||
82 !base::StringToInt(client_handle_string, &client_handle_value)) { 82 !base::StringToInt(client_handle_string, &client_handle_value)) {
83 LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; 83 LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch;
84 return ScopedPlatformHandle(); 84 return ScopedPlatformHandle();
85 } 85 }
86 86
87 return ScopedPlatformHandle( 87 return ScopedPlatformHandle(
88 PlatformHandle(LongToHandle(client_handle_value))); 88 PlatformHandle(LongToHandle(client_handle_value)));
89 } 89 }
90 90
91 void PlatformChannelPair::PrepareToPassClientHandleToChildProcess( 91 void PlatformChannelPair::PrepareToPassClientHandleToChildProcess(
92 CommandLine* command_line, 92 base::CommandLine* command_line,
93 base::HandlesToInheritVector* handle_passing_info) const { 93 base::HandlesToInheritVector* handle_passing_info) const {
94 DCHECK(command_line); 94 DCHECK(command_line);
95 DCHECK(handle_passing_info); 95 DCHECK(handle_passing_info);
96 DCHECK(client_handle_.is_valid()); 96 DCHECK(client_handle_.is_valid());
97 97
98 CHECK_GE(base::win::GetVersion(), base::win::VERSION_VISTA); 98 CHECK_GE(base::win::GetVersion(), base::win::VERSION_VISTA);
99 99
100 handle_passing_info->push_back(client_handle_.get().handle); 100 handle_passing_info->push_back(client_handle_.get().handle);
101 101
102 // Log a warning if the command line already has the switch, but "clobber" it 102 // Log a warning if the command line already has the switch, but "clobber" it
103 // anyway, since it's reasonably likely that all the switches were just copied 103 // anyway, since it's reasonably likely that all the switches were just copied
104 // from the parent. 104 // from the parent.
105 LOG_IF(WARNING, command_line->HasSwitch(kMojoPlatformChannelHandleSwitch)) 105 LOG_IF(WARNING, command_line->HasSwitch(kMojoPlatformChannelHandleSwitch))
106 << "Child command line already has switch --" 106 << "Child command line already has switch --"
107 << kMojoPlatformChannelHandleSwitch << "=" 107 << kMojoPlatformChannelHandleSwitch << "="
108 << command_line->GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch); 108 << command_line->GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch);
109 // (Any existing switch won't actually be removed from the command line, but 109 // (Any existing switch won't actually be removed from the command line, but
110 // the last one appended takes precedence.) 110 // the last one appended takes precedence.)
111 command_line->AppendSwitchASCII( 111 command_line->AppendSwitchASCII(
112 kMojoPlatformChannelHandleSwitch, 112 kMojoPlatformChannelHandleSwitch,
113 base::IntToString(HandleToLong(client_handle_.get().handle))); 113 base::IntToString(HandleToLong(client_handle_.get().handle)));
114 } 114 }
115 115
116 } // namespace embedder 116 } // namespace embedder
117 } // namespace mojo 117 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/embedder/platform_channel_pair_posix.cc ('k') | mojo/examples/aura_demo/aura_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698