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

Unified Diff: base/mac/foundation_util.mm

Issue 8540021: Create a nicer interface for base::mac::GetValueFromDictionary (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: COMPILE_ASSERT the arraysizes Created 9 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 side-by-side diff with in-line comments
Download patch
Index: base/mac/foundation_util.mm
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index 8a4ce471765e1157886e293ae4c7b9007ccc24f7..effeb7a9ceb7406895f8ce4faa3c7ae8eec31a65 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -9,7 +9,6 @@
#include "base/file_path.h"
#include "base/logging.h"
-#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
namespace base {
@@ -200,6 +199,20 @@ FilePath GetAppBundlePath(const FilePath& exec_name) {
return FilePath();
}
+std::string GetValueFromDictionaryErrorMessage(CFStringRef key,
+ CFStringRef expected_type_ref,
+ CFTypeRef value) {
+ ScopedCFTypeRef<CFStringRef> actual_type_ref(
+ CFCopyTypeIDDescription(CFGetTypeID(value)));
+ return "Expected value for key "
Mark Mentovai 2011/11/13 01:28:22 http://dev.chromium.org/developers/coding-style#TO
+ + base::SysCFStringRefToUTF8(key)
+ + " to be "
+ + base::SysCFStringRefToUTF8(expected_type_ref)
+ + " but it was "
+ + base::SysCFStringRefToUTF8(actual_type_ref)
+ + " instead";
+}
+
CFTypeRef GetValueFromDictionary(CFDictionaryRef dict,
CFStringRef key,
CFTypeID expected_type) {
@@ -209,16 +222,10 @@ CFTypeRef GetValueFromDictionary(CFDictionaryRef dict,
if (CFGetTypeID(value) != expected_type) {
ScopedCFTypeRef<CFStringRef> expected_type_ref(
- CFCopyTypeIDDescription(expected_type));
- ScopedCFTypeRef<CFStringRef> actual_type_ref(
- CFCopyTypeIDDescription(CFGetTypeID(value)));
- DLOG(WARNING) << "Expected value for key "
- << base::SysCFStringRefToUTF8(key)
- << " to be "
- << base::SysCFStringRefToUTF8(expected_type_ref)
- << " but it was "
- << base::SysCFStringRefToUTF8(actual_type_ref)
- << " instead";
+ CFCopyTypeIDDescription(expected_type));
Mark Mentovai 2011/11/13 01:28:22 Why did you change the correct four-space indent o
KushalP 2011/11/13 12:30:27 I'm not entirely sure. I must have done it manuall
+ DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key,
+ expected_type_ref,
+ value);
return NULL;
}

Powered by Google App Engine
This is Rietveld 408576698