Index: base/mac/mac_util.mm |
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm |
index 7f3be186daa8c0da82e4b5d58f21b1d70f27d756..14c0ce34f763fbefa2e442e84a034e083964659f 100644 |
--- a/base/mac/mac_util.mm |
+++ b/base/mac/mac_util.mm |
@@ -482,3 +482,26 @@ bool WasLaunchedAsHiddenLoginItem() { |
} // namespace mac |
} // namespace base |
+ |
+std::ostream& operator<<(std::ostream& o, const CFStringRef string) { |
+ return o << base::SysCFStringRefToUTF8(string); |
+} |
+ |
+std::ostream& operator<<(std::ostream& o, const CFErrorRef err) { |
+ base::mac::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err)); |
+ base::mac::ScopedCFTypeRef<CFDictionaryRef> user_info( |
+ CFErrorCopyUserInfo(err)); |
+ CFStringRef errorDesc = NULL; |
+ if (user_info.get()) { |
+ errorDesc = reinterpret_cast<CFStringRef>( |
+ CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); |
+ } |
+ o << "Code: " << CFErrorGetCode(err) |
+ << " Domain: " << CFErrorGetDomain(err) |
+ << " Desc: " << desc.get(); |
+ if(errorDesc) { |
+ o << "(" << errorDesc << ")"; |
+ } |
+ return o; |
+} |
+ |