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 27 matching lines...) Expand all Loading... |
38 void WebThreadSafeData::reset() | 38 void WebThreadSafeData::reset() |
39 { | 39 { |
40 m_private.reset(); | 40 m_private.reset(); |
41 } | 41 } |
42 | 42 |
43 void WebThreadSafeData::assign(const WebThreadSafeData& other) | 43 void WebThreadSafeData::assign(const WebThreadSafeData& other) |
44 { | 44 { |
45 m_private = other.m_private; | 45 m_private = other.m_private; |
46 } | 46 } |
47 | 47 |
| 48 void WebThreadSafeData::assign(const char* data, size_t length) |
| 49 { |
| 50 m_private = RawData::create().leakRef(); |
| 51 m_private->mutableData()->append(data, length); |
| 52 } |
| 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 |
67 WebThreadSafeData& WebThreadSafeData::operator=(const PassRefPtr<RawData>& data) | 73 WebThreadSafeData& WebThreadSafeData::operator=(const PassRefPtr<RawData>& data) |
68 { | 74 { |
69 m_private = data; | 75 m_private = data; |
70 return *this; | 76 return *this; |
71 } | 77 } |
72 | 78 |
73 } // namespace blink | 79 } // namespace blink |
OLD | NEW |