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

Side by Side Diff: client/crashpad_client_mac.cc

Issue 1405273002: Mach port scopers should use get() instead of type conversion operators (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: More is_valid() Created 5 years, 2 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
« no previous file with comments | « no previous file | client/simulate_crash_mac.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 Crashpad Authors. All rights reserved. 1 // Copyright 2014 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 CrashpadClient::~CrashpadClient() { 86 CrashpadClient::~CrashpadClient() {
87 } 87 }
88 88
89 bool CrashpadClient::StartHandler( 89 bool CrashpadClient::StartHandler(
90 const base::FilePath& handler, 90 const base::FilePath& handler,
91 const base::FilePath& database, 91 const base::FilePath& database,
92 const std::string& url, 92 const std::string& url,
93 const std::map<std::string, std::string>& annotations, 93 const std::map<std::string, std::string>& annotations,
94 const std::vector<std::string>& arguments) { 94 const std::vector<std::string>& arguments) {
95 DCHECK_EQ(exception_port_, kMachPortNull); 95 DCHECK(!exception_port_.is_valid());
96 96
97 // Set up the arguments for execve() first. These aren’t needed until execve() 97 // Set up the arguments for execve() first. These aren’t needed until execve()
98 // is called, but it’s dangerous to do this in a child process after fork(). 98 // is called, but it’s dangerous to do this in a child process after fork().
99 ChildPortHandshake child_port_handshake; 99 ChildPortHandshake child_port_handshake;
100 int handshake_fd = child_port_handshake.ReadPipeFD(); 100 int handshake_fd = child_port_handshake.ReadPipeFD();
101 101
102 // Use handler as argv[0], followed by arguments directed by this method’s 102 // Use handler as argv[0], followed by arguments directed by this method’s
103 // parameters and a --handshake-fd argument. |arguments| are added first so 103 // parameters and a --handshake-fd argument. |arguments| are added first so
104 // that if it erroneously contains an argument such as --url, the actual |url| 104 // that if it erroneously contains an argument such as --url, the actual |url|
105 // argument passed to this method will supersede it. In normal command-line 105 // argument passed to this method will supersede it. In normal command-line
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 LOG(WARNING) << "intermediate process: signal " << WTERMSIG(status); 204 LOG(WARNING) << "intermediate process: signal " << WTERMSIG(status);
205 } else if (!WIFEXITED(status)) { 205 } else if (!WIFEXITED(status)) {
206 DLOG(WARNING) << "intermediate process: unknown termination " << status; 206 DLOG(WARNING) << "intermediate process: unknown termination " << status;
207 } else if (WEXITSTATUS(status) != EXIT_SUCCESS) { 207 } else if (WEXITSTATUS(status) != EXIT_SUCCESS) {
208 LOG(WARNING) << "intermediate process: exit status " << WEXITSTATUS(status); 208 LOG(WARNING) << "intermediate process: exit status " << WEXITSTATUS(status);
209 } 209 }
210 210
211 // Rendezvous with the handler running in the grandchild process. 211 // Rendezvous with the handler running in the grandchild process.
212 exception_port_.reset(child_port_handshake.RunServer()); 212 exception_port_.reset(child_port_handshake.RunServer());
213 213
214 return exception_port_ ? true : false; 214 return exception_port_.is_valid();
215 } 215 }
216 216
217 bool CrashpadClient::UseHandler() { 217 bool CrashpadClient::UseHandler() {
218 DCHECK_NE(exception_port_, kMachPortNull); 218 DCHECK(exception_port_.is_valid());
219 219
220 return SetCrashExceptionPorts(exception_port_); 220 return SetCrashExceptionPorts(exception_port_.get());
221 } 221 }
222 222
223 // static 223 // static
224 void CrashpadClient::UseSystemDefaultHandler() { 224 void CrashpadClient::UseSystemDefaultHandler() {
225 base::mac::ScopedMachSendRight 225 base::mac::ScopedMachSendRight
226 system_crash_reporter_handler(SystemCrashReporterHandler()); 226 system_crash_reporter_handler(SystemCrashReporterHandler());
227 227
228 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL 228 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL
229 // to clear the current exception ports. 229 // to clear the current exception ports.
230 if (!SetCrashExceptionPorts(system_crash_reporter_handler)) { 230 if (!SetCrashExceptionPorts(system_crash_reporter_handler.get())) {
231 SetCrashExceptionPorts(MACH_PORT_NULL); 231 SetCrashExceptionPorts(MACH_PORT_NULL);
232 } 232 }
233 } 233 }
234 234
235 } // namespace crashpad 235 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | client/simulate_crash_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698