OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/push_messaging/PushMessageData.h" | 5 #include "modules/push_messaging/PushMessageData.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // be set in the PushEvent. | 25 // be set in the PushEvent. |
26 if (message_string.IsNull()) | 26 if (message_string.IsNull()) |
27 return nullptr; | 27 return nullptr; |
28 return PushMessageData::Create( | 28 return PushMessageData::Create( |
29 ArrayBufferOrArrayBufferViewOrUSVString::fromUSVString(message_string)); | 29 ArrayBufferOrArrayBufferViewOrUSVString::fromUSVString(message_string)); |
30 } | 30 } |
31 | 31 |
32 PushMessageData* PushMessageData::Create( | 32 PushMessageData* PushMessageData::Create( |
33 const ArrayBufferOrArrayBufferViewOrUSVString& message_data) { | 33 const ArrayBufferOrArrayBufferViewOrUSVString& message_data) { |
34 if (message_data.isArrayBuffer() || message_data.isArrayBufferView()) { | 34 if (message_data.isArrayBuffer() || message_data.isArrayBufferView()) { |
35 DOMArrayBuffer* buffer = message_data.isArrayBufferView() | 35 DOMArrayBuffer* buffer = |
36 ? message_data.getAsArrayBufferView()->buffer() | 36 message_data.isArrayBufferView() |
37 : message_data.getAsArrayBuffer(); | 37 ? message_data.getAsArrayBufferView().View()->buffer() |
| 38 : message_data.getAsArrayBuffer(); |
38 | 39 |
39 return new PushMessageData(static_cast<const char*>(buffer->Data()), | 40 return new PushMessageData(static_cast<const char*>(buffer->Data()), |
40 buffer->ByteLength()); | 41 buffer->ByteLength()); |
41 } | 42 } |
42 | 43 |
43 if (message_data.isUSVString()) { | 44 if (message_data.isUSVString()) { |
44 CString encoded_string = UTF8Encoding().Encode( | 45 CString encoded_string = UTF8Encoding().Encode( |
45 message_data.getAsUSVString(), WTF::kEntitiesForUnencodables); | 46 message_data.getAsUSVString(), WTF::kEntitiesForUnencodables); |
46 return new PushMessageData(encoded_string.Data(), encoded_string.length()); | 47 return new PushMessageData(encoded_string.Data(), encoded_string.length()); |
47 } | 48 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return ScriptValue(script_state, parsed); | 84 return ScriptValue(script_state, parsed); |
84 } | 85 } |
85 | 86 |
86 String PushMessageData::text() const { | 87 String PushMessageData::text() const { |
87 return UTF8Encoding().Decode(data_.Data(), data_.size()); | 88 return UTF8Encoding().Decode(data_.Data(), data_.size()); |
88 } | 89 } |
89 | 90 |
90 DEFINE_TRACE(PushMessageData) {} | 91 DEFINE_TRACE(PushMessageData) {} |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
OLD | NEW |