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 "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/modules/v8/UnionTypesModules.h" | 10 #include "bindings/modules/v8/UnionTypesModules.h" |
11 #include "core/dom/DOMArrayBuffer.h" | 11 #include "core/dom/DOMArrayBuffer.h" |
12 #include "core/fileapi/Blob.h" | 12 #include "core/fileapi/Blob.h" |
13 #include "platform/blob/BlobData.h" | 13 #include "platform/blob/BlobData.h" |
14 #include "wtf/text/TextEncoding.h" | 14 #include "wtf/text/TextEncoding.h" |
15 #include <v8.h> | 15 #include <v8.h> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 PushMessageData* PushMessageData::create(const String& messageString) | 19 PushMessageData* PushMessageData::create(const String& messageString) |
20 { | 20 { |
21 // The standard supports both an empty but valid message and a null message. | |
22 // In case the message is explicitly null, return a null pointer which will | |
23 // be set in the PushEvent. | |
24 if (messageString.isNull()) { | |
Peter Beverloo
2016/01/25 17:39:07
micro nit: no curly brackets here either
harkness
2016/01/26 12:07:20
Done.
| |
25 return nullptr; | |
26 } | |
21 return PushMessageData::create(ArrayBufferOrArrayBufferViewOrUSVString::from USVString(messageString)); | 27 return PushMessageData::create(ArrayBufferOrArrayBufferViewOrUSVString::from USVString(messageString)); |
22 } | 28 } |
23 | 29 |
24 PushMessageData* PushMessageData::create(const ArrayBufferOrArrayBufferViewOrUSV String& messageData) | 30 PushMessageData* PushMessageData::create(const ArrayBufferOrArrayBufferViewOrUSV String& messageData) |
25 { | 31 { |
26 if (messageData.isArrayBuffer() || messageData.isArrayBufferView()) { | 32 if (messageData.isArrayBuffer() || messageData.isArrayBufferView()) { |
27 RefPtr<DOMArrayBuffer> buffer = messageData.isArrayBufferView() | 33 RefPtr<DOMArrayBuffer> buffer = messageData.isArrayBufferView() |
28 ? messageData.getAsArrayBufferView()->buffer() | 34 ? messageData.getAsArrayBufferView()->buffer() |
29 : messageData.getAsArrayBuffer(); | 35 : messageData.getAsArrayBuffer(); |
30 | 36 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 String PushMessageData::text() const | 96 String PushMessageData::text() const |
91 { | 97 { |
92 return UTF8Encoding().decode(m_data.data(), m_data.size()); | 98 return UTF8Encoding().decode(m_data.data(), m_data.size()); |
93 } | 99 } |
94 | 100 |
95 DEFINE_TRACE(PushMessageData) | 101 DEFINE_TRACE(PushMessageData) |
96 { | 102 { |
97 } | 103 } |
98 | 104 |
99 } // namespace blink | 105 } // namespace blink |
OLD | NEW |