diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
commit | 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch) | |
tree | 4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/mac/SharedBufferMac.mm | |
parent | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff) | |
download | external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/mac/SharedBufferMac.mm')
-rw-r--r-- | WebCore/platform/mac/SharedBufferMac.mm | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/WebCore/platform/mac/SharedBufferMac.mm b/WebCore/platform/mac/SharedBufferMac.mm index c3753c2..ecf01c7 100644 --- a/WebCore/platform/mac/SharedBufferMac.mm +++ b/WebCore/platform/mac/SharedBufferMac.mm @@ -30,6 +30,10 @@ #include <string.h> #include <wtf/PassRefPtr.h> +#ifdef BUILDING_ON_TIGER +typedef unsigned NSUInteger; +#endif + using namespace WebCore; @interface WebCoreSharedBufferData : NSData @@ -51,6 +55,9 @@ using namespace WebCore; - (void)dealloc { + if (WebCoreObjCScheduleDeallocateOnMainThread([WebCoreSharedBufferData class], self)) + return; + sharedBuffer->deref(); [super dealloc]; @@ -75,7 +82,7 @@ using namespace WebCore; return self; } -- (unsigned)length +- (NSUInteger)length { return sharedBuffer->size(); } @@ -91,12 +98,7 @@ namespace WebCore { PassRefPtr<SharedBuffer> SharedBuffer::wrapNSData(NSData *nsData) { - return new SharedBuffer(nsData); -} - -SharedBuffer::SharedBuffer(NSData *nsData) - : m_nsData(nsData) -{ + return adoptRef(new SharedBuffer((CFDataRef)nsData)); } NSData *SharedBuffer::createNSData() @@ -105,40 +107,13 @@ NSData *SharedBuffer::createNSData() } CFDataRef SharedBuffer::createCFData() -{ - return (CFDataRef)HardRetainWithNSRelease([[WebCoreSharedBufferData alloc] initWithSharedBuffer:this]); -} - -bool SharedBuffer::hasPlatformData() const -{ - return m_nsData; -} - -const char* SharedBuffer::platformData() const -{ - return (const char*)[m_nsData.get() bytes]; -} - -unsigned SharedBuffer::platformDataSize() const -{ - return [m_nsData.get() length]; -} - -void SharedBuffer::maybeTransferPlatformData() { - if (!m_nsData) - return; + if (m_cfData) { + CFRetain(m_cfData.get()); + return m_cfData.get(); + } - ASSERT(m_buffer.size() == 0); - - m_buffer.append(reinterpret_cast<const char*>([m_nsData.get() bytes]), [m_nsData.get() length]); - - m_nsData = nil; -} - -void SharedBuffer::clearPlatformData() -{ - m_nsData = 0; + return (CFDataRef)HardRetainWithNSRelease([[WebCoreSharedBufferData alloc] initWithSharedBuffer:this]); } PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath) |