Bug 913953 - Part d: Remove unused conversion code to CFStringRef and NSString; r=ehsan

This commit is contained in:
Ms2ger 2013-09-10 09:03:31 +02:00
parent 078b7cbfe8
commit 0efa453cb9
3 changed files with 0 additions and 73 deletions

View File

@ -1,37 +0,0 @@
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_FOUNDATION_UTILS_MAC_H_
#define BASE_FOUNDATION_UTILS_MAC_H_
#include <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
// CFTypeRefToNSObjectAutorelease transfers ownership of a Core Foundation
// object (one derived from CFTypeRef) to the Foundation memory management
// system. In a traditional managed-memory environment, cf_object is
// autoreleased and returned as an NSObject. In a garbage-collected
// environment, cf_object is marked as eligible for garbage collection.
//
// This function should only be used to convert a concrete CFTypeRef type to
// its equivalent "toll-free bridged" NSObject subclass, for example,
// converting a CFStringRef to NSString.
//
// By calling this function, callers relinquish any ownership claim to
// cf_object. In a managed-memory environment, the object's ownership will be
// managed by the innermost NSAutoreleasePool, so after this function returns,
// callers should not assume that cf_object is valid any longer than the
// returned NSObject.
static inline id CFTypeRefToNSObjectAutorelease(CFTypeRef cf_object) {
// When GC is on, NSMakeCollectable marks cf_object for GC and autorelease
// is a no-op.
//
// In the traditional GC-less environment, NSMakeCollectable is a no-op,
// and cf_object is autoreleased, balancing out the caller's ownership claim.
//
// NSMakeCollectable returns nil when used on a NULL object.
return [NSMakeCollectable(cf_object) autorelease];
}
#endif // BASE_FOUNDATION_UTILS_MAC_H_

View File

@ -55,17 +55,6 @@ std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page);
// Converts between STL strings and CFStringRefs/NSStrings.
// Creates a string, and returns it with a refcount of 1. You are responsible
// for releasing it. Returns NULL on failure.
CFStringRef SysUTF8ToCFStringRef(const std::string& utf8);
CFStringRef SysUTF16ToCFStringRef(const string16& utf16);
CFStringRef SysWideToCFStringRef(const std::wstring& wide);
// Same, but returns an autoreleased NSString.
NSString* SysUTF8ToNSString(const std::string& utf8);
NSString* SysUTF16ToNSString(const string16& utf16);
NSString* SysWideToNSString(const std::wstring& wide);
// Converts a CFStringRef to an STL string. Returns an empty string on failure.
std::string SysCFStringRefToUTF8(CFStringRef ref);
string16 SysCFStringRefToUTF16(CFStringRef ref);

View File

@ -8,7 +8,6 @@
#include <vector>
#include "base/foundation_utils_mac.h"
#include "base/scoped_cftyperef.h"
#include "base/string_piece.h"
@ -144,30 +143,6 @@ std::wstring SysNativeMBToWide(const StringPiece& native_mb) {
return SysUTF8ToWide(native_mb);
}
CFStringRef SysUTF8ToCFStringRef(const std::string& utf8) {
return STLStringToCFStringWithEncodingsT(utf8, kNarrowStringEncoding);
}
CFStringRef SysUTF16ToCFStringRef(const string16& utf16) {
return STLStringToCFStringWithEncodingsT(utf16, kMediumStringEncoding);
}
CFStringRef SysWideToCFStringRef(const std::wstring& wide) {
return STLStringToCFStringWithEncodingsT(wide, kWideStringEncoding);
}
NSString* SysUTF8ToNSString(const std::string& utf8) {
return CFTypeRefToNSObjectAutorelease(SysUTF8ToCFStringRef(utf8));
}
NSString* SysUTF16ToNSString(const string16& utf16) {
return CFTypeRefToNSObjectAutorelease(SysUTF16ToCFStringRef(utf16));
}
NSString* SysWideToNSString(const std::wstring& wide) {
return CFTypeRefToNSObjectAutorelease(SysWideToCFStringRef(wide));
}
std::string SysCFStringRefToUTF8(CFStringRef ref) {
return CFStringToSTLStringWithEncodingT<std::string>(ref,
kNarrowStringEncoding);