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

Unified Diff: base/mac/foundation_util.mm

Issue 8769016: Use the new base::mac::GetValueFromDictionary<>() method. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update example comment 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
« no previous file with comments | « base/mac/foundation_util.h ('k') | base/mac/mac_util_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/foundation_util.mm
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index 6778c983a72c4c79920d7a7a97744182f72fd243..f1d277a9b036d11d6f645da3ba928bcda78d969a 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -217,40 +217,6 @@ TYPE_NAME_FOR_CF_TYPE_DEFN(CFString);
#undef TYPE_NAME_FOR_CF_TYPE_DEFN
-std::string GetValueFromDictionaryErrorMessage(
- CFStringRef key, const std::string& expected_type, CFTypeRef value) {
- ScopedCFTypeRef<CFStringRef> actual_type_ref(
- CFCopyTypeIDDescription(CFGetTypeID(value)));
- return "Expected value for key " +
- base::SysCFStringRefToUTF8(key) +
- " to be " +
- expected_type +
- " but it was " +
- base::SysCFStringRefToUTF8(actual_type_ref) +
- " instead";
-}
-
-CFTypeRef GetValueFromDictionary(CFDictionaryRef dict,
- CFStringRef key,
- CFTypeID expected_type) {
- CFTypeRef value = CFDictionaryGetValue(dict, key);
- if (!value)
- return value;
-
- if (CFGetTypeID(value) != expected_type) {
- ScopedCFTypeRef<CFStringRef> expected_type_name(
- CFCopyTypeIDDescription(expected_type));
- std::string expected_type_utf8 =
- base::SysCFStringRefToUTF8(expected_type_name);
- DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key,
- expected_type_utf8,
- value);
- return NULL;
- }
-
- return value;
-}
-
void NSObjectRetain(void* obj) {
id<NSObject> nsobj = static_cast<id<NSObject> >(obj);
[nsobj retain];
@@ -379,6 +345,19 @@ CF_CAST_DEFN(CFString);
#undef CF_CAST_DEFN
+std::string GetValueFromDictionaryErrorMessage(
+ CFStringRef key, const std::string& expected_type, CFTypeRef value) {
+ ScopedCFTypeRef<CFStringRef> actual_type_ref(
+ CFCopyTypeIDDescription(CFGetTypeID(value)));
+ return "Expected value for key " +
+ base::SysCFStringRefToUTF8(key) +
+ " to be " +
+ expected_type +
+ " but it was " +
+ base::SysCFStringRefToUTF8(actual_type_ref) +
+ " instead";
+}
+
} // namespace mac
} // namespace base
« no previous file with comments | « base/mac/foundation_util.h ('k') | base/mac/mac_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698