OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include <wtf/Forward.h> | 30 #include <wtf/Forward.h> |
31 #include <wtf/OwnPtr.h> | 31 #include <wtf/OwnPtr.h> |
32 #include <wtf/RefCounted.h> | 32 #include <wtf/RefCounted.h> |
33 #include <wtf/Vector.h> | 33 #include <wtf/Vector.h> |
34 #include <wtf/text/WTFString.h> | 34 #include <wtf/text/WTFString.h> |
35 | 35 |
36 #if USE(CF) | 36 #if USE(CF) |
37 #include <wtf/RetainPtr.h> | 37 #include <wtf/RetainPtr.h> |
38 #endif | 38 #endif |
39 | 39 |
40 #if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT)) | 40 #if PLATFORM(MAC) |
41 OBJC_CLASS NSData; | 41 OBJC_CLASS NSData; |
42 #endif | 42 #endif |
43 | 43 |
44 namespace WebCore { | 44 namespace WebCore { |
45 | 45 |
46 class PurgeableBuffer; | 46 class PurgeableBuffer; |
47 | 47 |
48 class SharedBuffer : public RefCounted<SharedBuffer> { | 48 class SharedBuffer : public RefCounted<SharedBuffer> { |
49 public: | 49 public: |
50 static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer)
; } | 50 static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer)
; } |
51 static PassRefPtr<SharedBuffer> create(size_t size) { return adoptRef(new Sh
aredBuffer(size)); } | 51 static PassRefPtr<SharedBuffer> create(size_t size) { return adoptRef(new Sh
aredBuffer(size)); } |
52 static PassRefPtr<SharedBuffer> create(const char* c, int i) { return adoptR
ef(new SharedBuffer(c, i)); } | 52 static PassRefPtr<SharedBuffer> create(const char* c, int i) { return adoptR
ef(new SharedBuffer(c, i)); } |
53 static PassRefPtr<SharedBuffer> create(const unsigned char* c, int i) { retu
rn adoptRef(new SharedBuffer(c, i)); } | 53 static PassRefPtr<SharedBuffer> create(const unsigned char* c, int i) { retu
rn adoptRef(new SharedBuffer(c, i)); } |
54 | 54 |
55 static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& fileP
ath); | 55 static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& fileP
ath); |
56 | 56 |
57 static PassRefPtr<SharedBuffer> adoptVector(Vector<char>& vector); | 57 static PassRefPtr<SharedBuffer> adoptVector(Vector<char>& vector); |
58 | 58 |
59 // The buffer must be in non-purgeable state before adopted to a SharedBuffe
r. | 59 // The buffer must be in non-purgeable state before adopted to a SharedBuffe
r. |
60 // It will stay that way until released. | 60 // It will stay that way until released. |
61 static PassRefPtr<SharedBuffer> adoptPurgeableBuffer(PassOwnPtr<PurgeableBuf
fer>); | 61 static PassRefPtr<SharedBuffer> adoptPurgeableBuffer(PassOwnPtr<PurgeableBuf
fer>); |
62 | 62 |
63 ~SharedBuffer(); | 63 ~SharedBuffer(); |
64 | 64 |
65 #if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT)) | 65 #if PLATFORM(MAC) |
66 NSData *createNSData(); | 66 NSData *createNSData(); |
67 static PassRefPtr<SharedBuffer> wrapNSData(NSData *data); | 67 static PassRefPtr<SharedBuffer> wrapNSData(NSData *data); |
68 #endif | 68 #endif |
69 #if USE(CF) | 69 #if USE(CF) |
70 CFDataRef createCFData(); | 70 CFDataRef createCFData(); |
71 static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef); | 71 static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef); |
72 #endif | 72 #endif |
73 | 73 |
74 // Calling this function will force internal segmented buffers | 74 // Calling this function will force internal segmented buffers |
75 // to be merged into a flat buffer. Use getSomeData() whenever possible | 75 // to be merged into a flat buffer. Use getSomeData() whenever possible |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 explicit SharedBuffer(CFDataRef); | 151 explicit SharedBuffer(CFDataRef); |
152 RetainPtr<CFDataRef> m_cfData; | 152 RetainPtr<CFDataRef> m_cfData; |
153 #endif | 153 #endif |
154 }; | 154 }; |
155 | 155 |
156 PassRefPtr<SharedBuffer> utf8Buffer(const String&); | 156 PassRefPtr<SharedBuffer> utf8Buffer(const String&); |
157 | 157 |
158 } // namespace WebCore | 158 } // namespace WebCore |
159 | 159 |
160 #endif // SharedBuffer_h | 160 #endif // SharedBuffer_h |
OLD | NEW |