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

Side by Side Diff: client/crashpad_client_win.cc

Issue 1406993008: win: Rename CrashpadClient::SetHandler() to SetHandlerIPCPipe() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Revise comment Created 5 years, 1 month 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 | « client/crashpad_client.h ('k') | handler/handler.gyp » ('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 Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 std::wstring FormatArgumentString(const std::string& name, 108 std::wstring FormatArgumentString(const std::string& name,
109 const std::wstring& value) { 109 const std::wstring& value) {
110 return std::wstring(L"--") + base::UTF8ToUTF16(name) + L"=" + value; 110 return std::wstring(L"--") + base::UTF8ToUTF16(name) + L"=" + value;
111 } 111 }
112 112
113 } // namespace 113 } // namespace
114 114
115 namespace crashpad { 115 namespace crashpad {
116 116
117 CrashpadClient::CrashpadClient() 117 CrashpadClient::CrashpadClient()
118 : ipc_port_() { 118 : ipc_pipe_() {
119 } 119 }
120 120
121 CrashpadClient::~CrashpadClient() { 121 CrashpadClient::~CrashpadClient() {
122 } 122 }
123 123
124 bool CrashpadClient::StartHandler( 124 bool CrashpadClient::StartHandler(
125 const base::FilePath& handler, 125 const base::FilePath& handler,
126 const base::FilePath& database, 126 const base::FilePath& database,
127 const std::string& url, 127 const std::string& url,
128 const std::map<std::string, std::string>& annotations, 128 const std::map<std::string, std::string>& annotations,
129 const std::vector<std::string>& arguments) { 129 const std::vector<std::string>& arguments) {
130 DCHECK(ipc_port_.empty()); 130 DCHECK(ipc_pipe_.empty());
131 131
132 ipc_port_ = 132 std::string ipc_pipe =
133 base::StringPrintf("\\\\.\\pipe\\crashpad_%d_", GetCurrentProcessId()); 133 base::StringPrintf("\\\\.\\pipe\\crashpad_%d_", GetCurrentProcessId());
134 for (int index = 0; index < 16; ++index) { 134 for (int index = 0; index < 16; ++index) {
135 ipc_port_.append(1, static_cast<char>(base::RandInt('A', 'Z'))); 135 ipc_pipe.append(1, static_cast<char>(base::RandInt('A', 'Z')));
136 } 136 }
137 ipc_pipe_ = base::UTF8ToUTF16(ipc_pipe);
137 138
138 std::wstring command_line; 139 std::wstring command_line;
139 AppendCommandLineArgument(handler.value(), &command_line); 140 AppendCommandLineArgument(handler.value(), &command_line);
140 for (const std::string& argument : arguments) { 141 for (const std::string& argument : arguments) {
141 AppendCommandLineArgument(base::UTF8ToUTF16(argument), &command_line); 142 AppendCommandLineArgument(base::UTF8ToUTF16(argument), &command_line);
142 } 143 }
143 if (!database.value().empty()) { 144 if (!database.value().empty()) {
144 AppendCommandLineArgument(FormatArgumentString("database", 145 AppendCommandLineArgument(FormatArgumentString("database",
145 database.value()), 146 database.value()),
146 &command_line); 147 &command_line);
147 } 148 }
148 if (!url.empty()) { 149 if (!url.empty()) {
149 AppendCommandLineArgument(FormatArgumentString("url", 150 AppendCommandLineArgument(FormatArgumentString("url",
150 base::UTF8ToUTF16(url)), 151 base::UTF8ToUTF16(url)),
151 &command_line); 152 &command_line);
152 } 153 }
153 for (const auto& kv : annotations) { 154 for (const auto& kv : annotations) {
154 AppendCommandLineArgument( 155 AppendCommandLineArgument(
155 FormatArgumentString("annotation", 156 FormatArgumentString("annotation",
156 base::UTF8ToUTF16(kv.first + '=' + kv.second)), 157 base::UTF8ToUTF16(kv.first + '=' + kv.second)),
157 &command_line); 158 &command_line);
158 } 159 }
159 AppendCommandLineArgument(FormatArgumentString("pipe-name", 160 AppendCommandLineArgument(FormatArgumentString("pipe-name", ipc_pipe_),
160 base::UTF8ToUTF16(ipc_port_)),
161 &command_line); 161 &command_line);
162 162
163 STARTUPINFO startup_info = {}; 163 STARTUPINFO startup_info = {};
164 startup_info.cb = sizeof(startup_info); 164 startup_info.cb = sizeof(startup_info);
165 startup_info.dwFlags = STARTF_USESTDHANDLES; 165 startup_info.dwFlags = STARTF_USESTDHANDLES;
166 startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); 166 startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
167 startup_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); 167 startup_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
168 startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); 168 startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
169 PROCESS_INFORMATION process_info; 169 PROCESS_INFORMATION process_info;
170 BOOL rv = CreateProcess(handler.value().c_str(), 170 BOOL rv = CreateProcess(handler.value().c_str(),
(...skipping 13 matching lines...) Expand all
184 184
185 rv = CloseHandle(process_info.hThread); 185 rv = CloseHandle(process_info.hThread);
186 PLOG_IF(WARNING, !rv) << "CloseHandle thread"; 186 PLOG_IF(WARNING, !rv) << "CloseHandle thread";
187 187
188 rv = CloseHandle(process_info.hProcess); 188 rv = CloseHandle(process_info.hProcess);
189 PLOG_IF(WARNING, !rv) << "CloseHandle process"; 189 PLOG_IF(WARNING, !rv) << "CloseHandle process";
190 190
191 return true; 191 return true;
192 } 192 }
193 193
194 bool CrashpadClient::SetHandler(const std::string& ipc_port) { 194 bool CrashpadClient::SetHandlerIPCPipe(const std::wstring& ipc_pipe) {
195 DCHECK(ipc_port_.empty()); 195 DCHECK(ipc_pipe_.empty());
196 DCHECK(!ipc_port.empty()); 196 DCHECK(!ipc_pipe.empty());
197 197
198 ipc_port_ = ipc_port; 198 ipc_pipe_ = ipc_pipe;
199 199
200 return true; 200 return true;
201 } 201 }
202 202
203 bool CrashpadClient::UseHandler() { 203 bool CrashpadClient::UseHandler() {
204 DCHECK(!ipc_port_.empty()); 204 DCHECK(!ipc_pipe_.empty());
205 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE); 205 DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE);
206 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE); 206 DCHECK_EQ(g_signal_non_crash_dump, INVALID_HANDLE_VALUE);
207 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE); 207 DCHECK_EQ(g_non_crash_dump_done, INVALID_HANDLE_VALUE);
208 DCHECK(!g_critical_section_with_debug_info.DebugInfo); 208 DCHECK(!g_critical_section_with_debug_info.DebugInfo);
209 209
210 ClientToServerMessage message; 210 ClientToServerMessage message;
211 memset(&message, 0, sizeof(message)); 211 memset(&message, 0, sizeof(message));
212 message.type = ClientToServerMessage::kRegister; 212 message.type = ClientToServerMessage::kRegister;
213 message.registration.version = RegistrationRequest::kMessageVersion; 213 message.registration.version = RegistrationRequest::kMessageVersion;
214 message.registration.client_process_id = GetCurrentProcessId(); 214 message.registration.client_process_id = GetCurrentProcessId();
(...skipping 10 matching lines...) Expand all
225 // of the list. But that is not an exported symbol, so on an arbitrary client 225 // of the list. But that is not an exported symbol, so on an arbitrary client
226 // machine, we don't have a way of getting that pointer. 226 // machine, we don't have a way of getting that pointer.
227 if (InitializeCriticalSectionWithDebugInfoIfPossible( 227 if (InitializeCriticalSectionWithDebugInfoIfPossible(
228 &g_critical_section_with_debug_info)) { 228 &g_critical_section_with_debug_info)) {
229 message.registration.critical_section_address = 229 message.registration.critical_section_address =
230 reinterpret_cast<WinVMAddress>(&g_critical_section_with_debug_info); 230 reinterpret_cast<WinVMAddress>(&g_critical_section_with_debug_info);
231 } 231 }
232 232
233 ServerToClientMessage response = {0}; 233 ServerToClientMessage response = {0};
234 234
235 if (!SendToCrashHandlerServer( 235 if (!SendToCrashHandlerServer(ipc_pipe_, message, &response)) {
236 base::UTF8ToUTF16(ipc_port_), message, &response)) {
237 return false; 236 return false;
238 } 237 }
239 238
240 // The server returns these already duplicated to be valid in this process. 239 // The server returns these already duplicated to be valid in this process.
241 g_signal_exception = reinterpret_cast<HANDLE>( 240 g_signal_exception = reinterpret_cast<HANDLE>(
242 static_cast<uintptr_t>(response.registration.request_crash_dump_event)); 241 static_cast<uintptr_t>(response.registration.request_crash_dump_event));
243 g_signal_non_crash_dump = reinterpret_cast<HANDLE>(static_cast<uintptr_t>( 242 g_signal_non_crash_dump = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(
244 response.registration.request_non_crash_dump_event)); 243 response.registration.request_non_crash_dump_event));
245 g_non_crash_dump_done = reinterpret_cast<HANDLE>(static_cast<uintptr_t>( 244 g_non_crash_dump_done = reinterpret_cast<HANDLE>(static_cast<uintptr_t>(
246 response.registration.non_crash_dump_completed_event)); 245 response.registration.non_crash_dump_completed_event));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 reinterpret_cast<crashpad::WinVMAddress>(&exception_pointers); 298 reinterpret_cast<crashpad::WinVMAddress>(&exception_pointers);
300 299
301 bool set_event_result = !!SetEvent(g_signal_non_crash_dump); 300 bool set_event_result = !!SetEvent(g_signal_non_crash_dump);
302 PLOG_IF(ERROR, !set_event_result) << "SetEvent"; 301 PLOG_IF(ERROR, !set_event_result) << "SetEvent";
303 302
304 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE); 303 DWORD wfso_result = WaitForSingleObject(g_non_crash_dump_done, INFINITE);
305 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject"; 304 PLOG_IF(ERROR, wfso_result != WAIT_OBJECT_0) << "WaitForSingleObject";
306 } 305 }
307 306
308 } // namespace crashpad 307 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crashpad_client.h ('k') | handler/handler.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698