| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class RawData; | 43 class RawData; |
| 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 BLINK_PLATFORM_EXPORT WebThreadSafeData(const char* data, size_t length); |
| 51 |
| 50 ~WebThreadSafeData() { reset(); } | 52 ~WebThreadSafeData() { reset(); } |
| 51 | 53 |
| 52 BLINK_PLATFORM_EXPORT void assign(const WebThreadSafeData&); | 54 BLINK_PLATFORM_EXPORT void assign(const WebThreadSafeData&); |
| 53 BLINK_PLATFORM_EXPORT void reset(); | 55 BLINK_PLATFORM_EXPORT void reset(); |
| 54 | 56 |
| 55 BLINK_PLATFORM_EXPORT size_t size() const; | 57 BLINK_PLATFORM_EXPORT size_t size() const; |
| 56 BLINK_PLATFORM_EXPORT const char* data() const; | 58 BLINK_PLATFORM_EXPORT const char* data() const; |
| 57 | 59 |
| 58 bool isEmpty() const { return !size(); } | 60 bool isEmpty() const { return !size(); } |
| 59 | 61 |
| 62 BLINK_PLATFORM_EXPORT WebThreadSafeData(const WebThreadSafeData&); |
| 63 BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(const WebThreadSafeData&)
; |
| 64 |
| 60 #if INSIDE_BLINK | 65 #if INSIDE_BLINK |
| 61 BLINK_PLATFORM_EXPORT WebThreadSafeData(const WTF::PassRefPtr<RawData>&); | 66 BLINK_PLATFORM_EXPORT WebThreadSafeData(const WTF::PassRefPtr<RawData>&); |
| 62 BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(const WTF::PassRefPtr<Raw
Data>&); | 67 BLINK_PLATFORM_EXPORT WebThreadSafeData& operator=(const WTF::PassRefPtr<Raw
Data>&); |
| 63 #else | 68 #else |
| 64 operator std::string() const | 69 operator std::string() const |
| 65 { | 70 { |
| 66 size_t len = size(); | 71 size_t len = size(); |
| 67 return len ? std::string(data(), len) : std::string(); | 72 return len ? std::string(data(), len) : std::string(); |
| 68 } | 73 } |
| 69 #endif | 74 #endif |
| 70 | 75 |
| 71 private: | 76 private: |
| 72 WebPrivatePtr<RawData> m_private; | 77 WebPrivatePtr<RawData> m_private; |
| 73 }; | 78 }; |
| 74 | 79 |
| 75 } // namespace blink | 80 } // namespace blink |
| 76 | 81 |
| 77 #endif | 82 #endif |
| OLD | NEW |