| 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 (messageString.isNull()) | 26 if (messageString.isNull()) |
| 27 return nullptr; | 27 return nullptr; |
| 28 return PushMessageData::create( | 28 return PushMessageData::create( |
| 29 ArrayBufferOrArrayBufferViewOrUSVString::fromUSVString(messageString)); | 29 ArrayBufferOrArrayBufferViewOrUSVString::fromUSVString(messageString)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 PushMessageData* PushMessageData::create( | 32 PushMessageData* PushMessageData::create( |
| 33 const ArrayBufferOrArrayBufferViewOrUSVString& messageData) { | 33 const ArrayBufferOrArrayBufferViewOrUSVString& messageData) { |
| 34 if (messageData.isArrayBuffer() || messageData.isArrayBufferView()) { | 34 if (messageData.isArrayBuffer() || messageData.isArrayBufferView()) { |
| 35 DOMArrayBuffer* buffer = messageData.isArrayBufferView() | 35 DOMArrayBuffer* buffer = |
| 36 ? messageData.getAsArrayBufferView()->buffer() | 36 messageData.isArrayBufferView() |
| 37 : messageData.getAsArrayBuffer(); | 37 ? messageData.getAsArrayBufferView().view()->buffer() |
| 38 : messageData.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 (messageData.isUSVString()) { | 44 if (messageData.isUSVString()) { |
| 44 CString encodedString = UTF8Encoding().encode(messageData.getAsUSVString(), | 45 CString encodedString = UTF8Encoding().encode(messageData.getAsUSVString(), |
| 45 WTF::EntitiesForUnencodables); | 46 WTF::EntitiesForUnencodables); |
| 46 return new PushMessageData(encodedString.data(), encodedString.length()); | 47 return new PushMessageData(encodedString.data(), encodedString.length()); |
| 47 } | 48 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return ScriptValue(scriptState, parsed); | 83 return ScriptValue(scriptState, parsed); |
| 83 } | 84 } |
| 84 | 85 |
| 85 String PushMessageData::text() const { | 86 String PushMessageData::text() const { |
| 86 return UTF8Encoding().decode(m_data.data(), m_data.size()); | 87 return UTF8Encoding().decode(m_data.data(), m_data.size()); |
| 87 } | 88 } |
| 88 | 89 |
| 89 DEFINE_TRACE(PushMessageData) {} | 90 DEFINE_TRACE(PushMessageData) {} |
| 90 | 91 |
| 91 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |