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 17 matching lines...) Expand all Loading... |
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 #include "config.h" | 31 #include "config.h" |
32 #include "public/platform/WebThreadSafeData.h" | 32 #include "public/platform/WebThreadSafeData.h" |
33 | 33 |
34 #include "platform/blob/BlobData.h" | 34 #include "platform/blob/BlobData.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
| 38 WebThreadSafeData::WebThreadSafeData(const char* data, size_t length) |
| 39 { |
| 40 m_private = RawData::create().leakRef(); |
| 41 m_private->mutableData()->append(data, length); |
| 42 } |
| 43 |
38 void WebThreadSafeData::reset() | 44 void WebThreadSafeData::reset() |
39 { | 45 { |
40 m_private.reset(); | 46 m_private.reset(); |
41 } | 47 } |
42 | 48 |
43 void WebThreadSafeData::assign(const WebThreadSafeData& other) | 49 void WebThreadSafeData::assign(const WebThreadSafeData& other) |
44 { | 50 { |
45 m_private = other.m_private; | 51 m_private = other.m_private; |
46 } | 52 } |
47 | 53 |
48 size_t WebThreadSafeData::size() const | 54 size_t WebThreadSafeData::size() const |
49 { | 55 { |
50 if (m_private.isNull()) | 56 if (m_private.isNull()) |
51 return 0; | 57 return 0; |
52 return m_private->length(); | 58 return m_private->length(); |
53 } | 59 } |
54 | 60 |
55 const char* WebThreadSafeData::data() const | 61 const char* WebThreadSafeData::data() const |
56 { | 62 { |
57 if (m_private.isNull()) | 63 if (m_private.isNull()) |
58 return 0; | 64 return 0; |
59 return m_private->data(); | 65 return m_private->data(); |
60 } | 66 } |
61 | 67 |
62 WebThreadSafeData::WebThreadSafeData(const PassRefPtr<RawData>& data) | 68 WebThreadSafeData::WebThreadSafeData(const PassRefPtr<RawData>& data) |
63 : m_private(data.leakRef()) | 69 : m_private(data.leakRef()) |
64 { | 70 { |
65 } | 71 } |
66 | 72 |
| 73 WebThreadSafeData::WebThreadSafeData(const WebThreadSafeData& other) |
| 74 { |
| 75 m_private = other.m_private; |
| 76 } |
| 77 |
| 78 WebThreadSafeData& WebThreadSafeData::operator=(const WebThreadSafeData& other) |
| 79 { |
| 80 m_private = other.m_private; |
| 81 return *this; |
| 82 } |
| 83 |
67 WebThreadSafeData& WebThreadSafeData::operator=(const PassRefPtr<RawData>& data) | 84 WebThreadSafeData& WebThreadSafeData::operator=(const PassRefPtr<RawData>& data) |
68 { | 85 { |
69 m_private = data; | 86 m_private = data; |
70 return *this; | 87 return *this; |
71 } | 88 } |
72 | 89 |
73 } // namespace blink | 90 } // namespace blink |
OLD | NEW |