2008-03-19 Stephanie Lewis <slewis@apple.com>
[WebKit-https.git] / WebCore / platform / SharedBuffer.h
index 0ab7ef5c4c3f8137cbe75bb5ec08ed872389334b..9ce1f129d71385c5214a8b6ef501b927761aac6b 100644 (file)
 #include <wtf/Forward.h>
 #include <wtf/Vector.h>
 
 #include <wtf/Forward.h>
 #include <wtf/Vector.h>
 
-#if PLATFORM(MAC)
+#if PLATFORM(CF)
 #include <wtf/RetainPtr.h>
 #include <wtf/RetainPtr.h>
+#endif
 
 
+#if PLATFORM(MAC)
 #ifdef __OBJC__
 @class NSData;
 #else
 #ifdef __OBJC__
 @class NSData;
 #else
@@ -45,18 +47,20 @@ namespace WebCore {
 
 class SharedBuffer : public RefCounted<SharedBuffer> {
 public:
 
 class SharedBuffer : public RefCounted<SharedBuffer> {
 public:
-    SharedBuffer();
-    SharedBuffer(const char*, int);
-    SharedBuffer(const unsigned char*, int);
+    static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer); }
+    static PassRefPtr<SharedBuffer> create(const char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
+    static PassRefPtr<SharedBuffer> create(const unsigned char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
 
     static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
     
 #if PLATFORM(MAC)
     NSData *createNSData();
 
     static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
     
 #if PLATFORM(MAC)
     NSData *createNSData();
-    CFDataRef createCFData();
     static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
 #endif
     static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
 #endif
-        
+#if PLATFORM(CF)
+    CFDataRef createCFData();
+#endif
+
     const char* data() const;
     unsigned size() const;
     const Vector<char> &buffer() { return m_buffer; }
     const char* data() const;
     unsigned size() const;
     const Vector<char> &buffer() { return m_buffer; }
@@ -71,14 +75,18 @@ public:
     PassRefPtr<SharedBuffer> copy() const;
     
 private:
     PassRefPtr<SharedBuffer> copy() const;
     
 private:
+    SharedBuffer();
+    SharedBuffer(const char*, int);
+    SharedBuffer(const unsigned char*, int);
+    
     void clearPlatformData();
     void maybeTransferPlatformData();
     bool hasPlatformData() const;
     
     Vector<char> m_buffer;
     void clearPlatformData();
     void maybeTransferPlatformData();
     bool hasPlatformData() const;
     
     Vector<char> m_buffer;
-#if PLATFORM(MAC)
-    SharedBuffer(NSData *nsdata);
-    RetainPtr<NSData> m_nsData;
+#if PLATFORM(CF)
+    SharedBuffer(CFDataRef);
+    RetainPtr<CFDataRef> m_cfData;
 #endif
 };
     
 #endif
 };