| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebThreadSafeData_h | 31 #ifndef WebThreadSafeData_h |
| 32 #define WebThreadSafeData_h | 32 #define WebThreadSafeData_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "WebPrivatePtr.h" | 35 #include "WebPrivatePtr.h" |
| 36 | 36 |
| 37 #if !BLINK_IMPLEMENTATION | 37 #if !INSIDE_BLINK |
| 38 #include <string> | 38 #include <string> |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace WebCore { class RawData; } | 41 namespace WebCore { class RawData; } |
| 42 | 42 |
| 43 namespace WebKit { | 43 namespace WebKit { |
| 44 | 44 |
| 45 // A container for raw bytes. It is inexpensive to copy a WebThreadSafeData obje
ct. | 45 // A container for raw bytes. It is inexpensive to copy a WebThreadSafeData obje
ct. |
| 46 // It is safe to pass a WebThreadSafeData across threads!!! | 46 // It is safe to pass a WebThreadSafeData across threads!!! |
| 47 class WebThreadSafeData { | 47 class WebThreadSafeData { |
| 48 public: | 48 public: |
| 49 WebThreadSafeData() { } | 49 WebThreadSafeData() { } |
| 50 ~WebThreadSafeData() { reset(); } | 50 ~WebThreadSafeData() { reset(); } |
| 51 | 51 |
| 52 BLINK_EXPORT void assign(const WebThreadSafeData&); | 52 BLINK_PLATFORM_EXPORT void assign(const WebThreadSafeData&); |
| 53 BLINK_EXPORT void reset(); | 53 BLINK_PLATFORM_EXPORT void reset(); |
| 54 | 54 |
| 55 BLINK_EXPORT size_t size() const; | 55 BLINK_PLATFORM_EXPORT size_t size() const; |
| 56 BLINK_EXPORT const char* data() const; | 56 BLINK_PLATFORM_EXPORT const char* data() const; |
| 57 | 57 |
| 58 bool isEmpty() const { return !size(); } | 58 bool isEmpty() const { return !size(); } |
| 59 | 59 |
| 60 #if BLINK_IMPLEMENTATION | 60 #if INSIDE_BLINK |
| 61 WebThreadSafeData(const WTF::PassRefPtr<WebCore::RawData>&); | 61 BLINK_PLATFORM_EXPORT WebThreadSafeData(const WTF::PassRefPtr<WebCore::RawDa
ta>&); |
| 62 WebThreadSafeData& operator=(const WTF::PassRefPtr<WebCore::RawData>&); | 62 BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(const WTF::PassRefPtr<Web
Core::RawData>&); |
| 63 #else | 63 #else |
| 64 operator std::string() const | 64 operator std::string() const |
| 65 { | 65 { |
| 66 size_t len = size(); | 66 size_t len = size(); |
| 67 return len ? std::string(data(), len) : std::string(); | 67 return len ? std::string(data(), len) : std::string(); |
| 68 } | 68 } |
| 69 #endif | 69 #endif |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 WebPrivatePtr<WebCore::RawData> m_private; | 72 WebPrivatePtr<WebCore::RawData> m_private; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace WebKit | 75 } // namespace WebKit |
| 76 | 76 |
| 77 #endif | 77 #endif |
| OLD | NEW |