Address review comments from r843 (http://breakpad.appspot.com/307001)
Review URL: http://breakpad.appspot.com/308001

Cr-Mirrored-From: https://chromium.googlesource.com/breakpad/breakpad
Cr-Mirrored-Commit: 405bb7aff734100b8d25adfd93d42d54a778b9a4
diff --git a/client/mac/Framework/Breakpad.h b/client/mac/Framework/Breakpad.h
index fa86143..29bb3ec 100644
--- a/client/mac/Framework/Breakpad.h
+++ b/client/mac/Framework/Breakpad.h
@@ -94,6 +94,10 @@
 #define BREAKPAD_SERVER_PARAMETER_PREFIX  "BreakpadServerParameterPrefix_"
 #define BREAKPAD_ON_DEMAND                "BreakpadOnDemand"
 
+// A service name associated with the original bootstrap parent port, saved in
+// OnDemandServer and restored in Inspector.
+#define BREAKPAD_BOOTSTRAP_PARENT_PORT    "com.Breakpad.BootstrapParent"
+
 // Optional user-defined function to dec to decide if we should handle
 // this crash or forward it along.
 // Return true if you want Breakpad to handle it.
diff --git a/client/mac/Framework/OnDemandServer.mm b/client/mac/Framework/OnDemandServer.mm
index f736abd..43a2703 100644
--- a/client/mac/Framework/OnDemandServer.mm
+++ b/client/mac/Framework/OnDemandServer.mm
@@ -28,6 +28,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #import "OnDemandServer.h"
+#import "Breakpad.h"
 
 #if DEBUG
   #define PRINT_MACH_RESULT(result_, message_) \
@@ -81,7 +82,7 @@
 
   mach_port_t bootstrap_subset_port;
   kr = bootstrap_subset(bootstrap_port, self_task, &bootstrap_subset_port);
-  if (kr != KERN_SUCCESS) {
+  if (kr != BOOTSTRAP_SUCCESS) {
     PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_subset(): ");
     return kr;
   }
@@ -94,9 +95,9 @@
   // recover this port and set it as its own bootstrap port in Inspector.mm
   // Inspector::ResetBootstrapPort.
   kr = bootstrap_register(bootstrap_subset_port,
-                          const_cast<char*>("BootstrapParentPort"),
+                          const_cast<char*>(BREAKPAD_BOOTSTRAP_PARENT_PORT),
                           bootstrap_port);
-  if (kr != KERN_SUCCESS) {
+  if (kr != BOOTSTRAP_SUCCESS) {
     PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_register(): ");
     return kr;
   }
@@ -106,7 +107,7 @@
                                geteuid(),       // server uid
                                true,
                                &server_port_);
-  if (kr != KERN_SUCCESS) {
+  if (kr != BOOTSTRAP_SUCCESS) {
     PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_create_server(): ");
     return kr;
   }
@@ -118,13 +119,13 @@
   kr = bootstrap_create_service(server_port_,
                                 const_cast<char*>(service_name),
                                 &service_port_);
-  if (kr != KERN_SUCCESS) {
+  if (kr != BOOTSTRAP_SUCCESS) {
     PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_create_service(): ");
 
     // perhaps the service has already been created - try to look it up
     kr = bootstrap_look_up(bootstrap_port, (char*)service_name, &service_port_);
 
-    if (kr != KERN_SUCCESS) {
+    if (kr != BOOTSTRAP_SUCCESS) {
       PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_look_up(): ");
       Unregister();  // clean up server port
       return kr;
diff --git a/client/mac/crash_generation/Inspector.h b/client/mac/crash_generation/Inspector.h
index e670581..4148eac 100644
--- a/client/mac/crash_generation/Inspector.h
+++ b/client/mac/crash_generation/Inspector.h
@@ -175,7 +175,7 @@
   // (ensuring that children like the sender will inherit it), and saves the
   // subset in bootstrap_subset_port_ for use by ServiceCheckIn and
   // ServiceCheckOut.
-  void            ResetBootstrapPort();
+  kern_return_t   ResetBootstrapPort();
 
   kern_return_t   ServiceCheckIn(const char *receive_port_name);
   kern_return_t   ServiceCheckOut(const char *receive_port_name);
diff --git a/client/mac/crash_generation/Inspector.mm b/client/mac/crash_generation/Inspector.mm
index 7718708..47d3e7b 100644
--- a/client/mac/crash_generation/Inspector.mm
+++ b/client/mac/crash_generation/Inspector.mm
@@ -203,9 +203,12 @@
 
 //=============================================================================
 void Inspector::Inspect(const char *receive_port_name) {
-  ResetBootstrapPort();
+  kern_return_t result = ResetBootstrapPort();
+  if (result != KERN_SUCCESS) {
+    return;
+  }
 
-  kern_return_t result = ServiceCheckIn(receive_port_name);
+  result = ServiceCheckIn(receive_port_name);
 
   if (result == KERN_SUCCESS) {
     result = ReadMessages();
@@ -243,7 +246,7 @@
 }
 
 //=============================================================================
-void Inspector::ResetBootstrapPort() {
+kern_return_t Inspector::ResetBootstrapPort() {
   // A reasonable default, in case anything fails.
   bootstrap_subset_port_ = bootstrap_port;
 
@@ -254,29 +257,31 @@
   if (kr != KERN_SUCCESS) {
     NSLog(@"ResetBootstrapPort: task_get_bootstrap_port failed: %s (%d)",
           mach_error_string(kr), kr);
-    return;
+    return kr;
   }
 
   mach_port_t bootstrap_parent_port;
   kr = bootstrap_look_up(bootstrap_subset_port_,
-                         "BootstrapParentPort",
+                         const_cast<char*>(BREAKPAD_BOOTSTRAP_PARENT_PORT),
                          &bootstrap_parent_port);
-  if (kr != KERN_SUCCESS) {
+  if (kr != BOOTSTRAP_SUCCESS) {
     NSLog(@"ResetBootstrapPort: bootstrap_look_up failed: %s (%d)",
           bootstrap_strerror(kr), kr);
-    return;
+    return kr;
   }
 
   kr = task_set_bootstrap_port(self_task, bootstrap_parent_port);
   if (kr != KERN_SUCCESS) {
     NSLog(@"ResetBootstrapPort: task_set_bootstrap_port failed: %s (%d)",
           mach_error_string(kr), kr);
-    return;
+    return kr;
   }
 
   // Some things access the bootstrap port through this global variable
   // instead of calling task_get_bootstrap_port.
   bootstrap_port = bootstrap_parent_port;
+
+  return KERN_SUCCESS;
 }
 
 //=============================================================================