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

Unified Diff: third_party/crashpad/crashpad/client/crashpad_client_mac.cc

Issue 2754553002: Update Crashpad to 18d70acf81df49cc10b00bcc67c1ec64e16bd9d0 (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/crashpad/crashpad/client/crashpad_client_mac.cc
diff --git a/third_party/crashpad/crashpad/client/crashpad_client_mac.cc b/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
index cc50969e7c68e6f4820f1ee7bb20e643c3ae60ae..978024e511f935d86c1635b1d0f9c0fd6f77c1f9 100644
--- a/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
+++ b/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
@@ -523,7 +523,7 @@ class HandlerStarter final : public NotifyServer::DefaultInterface {
} // namespace
-CrashpadClient::CrashpadClient() {
+CrashpadClient::CrashpadClient() : exception_port_(MACH_PORT_NULL) {
}
CrashpadClient::~CrashpadClient() {
@@ -569,8 +569,42 @@ bool CrashpadClient::SetHandlerMachService(const std::string& service_name) {
bool CrashpadClient::SetHandlerMachPort(
base::mac::ScopedMachSendRight exception_port) {
+ DCHECK(!exception_port_.is_valid());
DCHECK(exception_port.is_valid());
- return SetCrashExceptionPorts(exception_port.get());
+
+ if (!SetCrashExceptionPorts(exception_port.get())) {
+ return false;
+ }
+
+ exception_port_.swap(exception_port);
+ return true;
+}
+
+base::mac::ScopedMachSendRight CrashpadClient::GetHandlerMachPort() const {
+ DCHECK(exception_port_.is_valid());
+
+ // For the purposes of this method, only return a port set by
+ // SetHandlerMachPort().
+ //
+ // It would be possible to use task_get_exception_ports() to look up the
+ // EXC_CRASH task exception port, but that’s probably not what users of this
+ // interface really want. If CrashpadClient is asked for the handler Mach
+ // port, it should only return a port that it knows about by virtue of having
+ // set it. It shouldn’t return any EXC_CRASH task exception port in effect if
+ // SetHandlerMachPort() was never called, and it shouldn’t return any
+ // EXC_CRASH task exception port that might be set by other code after
+ // SetHandlerMachPort() is called.
+ //
+ // The caller is accepting its own new ScopedMachSendRight, so increment the
+ // reference count of the underlying right.
+ kern_return_t kr = mach_port_mod_refs(
+ mach_task_self(), exception_port_.get(), MACH_PORT_RIGHT_SEND, 1);
+ if (kr != KERN_SUCCESS) {
+ MACH_LOG(ERROR, kr) << "mach_port_mod_refs";
+ return base::mac::ScopedMachSendRight(MACH_PORT_NULL);
+ }
+
+ return base::mac::ScopedMachSendRight(exception_port_.get());
}
// static
« no previous file with comments | « third_party/crashpad/crashpad/client/crashpad_client.h ('k') | third_party/crashpad/crashpad/doc/developing.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698