Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: third_party/WebKit/Source/modules/push_messaging/PushMessageData.cpp

Issue 2812833003: Revert of [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 = 35 DOMArrayBuffer* buffer = message_data.isArrayBufferView()
36 message_data.isArrayBufferView() 36 ? message_data.getAsArrayBufferView()->buffer()
37 ? message_data.getAsArrayBufferView().View()->buffer() 37 : message_data.getAsArrayBuffer();
38 : message_data.getAsArrayBuffer();
39 38
40 return new PushMessageData(static_cast<const char*>(buffer->Data()), 39 return new PushMessageData(static_cast<const char*>(buffer->Data()),
41 buffer->ByteLength()); 40 buffer->ByteLength());
42 } 41 }
43 42
44 if (message_data.isUSVString()) { 43 if (message_data.isUSVString()) {
45 CString encoded_string = UTF8Encoding().Encode( 44 CString encoded_string = UTF8Encoding().Encode(
46 message_data.getAsUSVString(), WTF::kEntitiesForUnencodables); 45 message_data.getAsUSVString(), WTF::kEntitiesForUnencodables);
47 return new PushMessageData(encoded_string.Data(), encoded_string.length()); 46 return new PushMessageData(encoded_string.Data(), encoded_string.length());
48 } 47 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return ScriptValue(script_state, parsed); 83 return ScriptValue(script_state, parsed);
85 } 84 }
86 85
87 String PushMessageData::text() const { 86 String PushMessageData::text() const {
88 return UTF8Encoding().Decode(data_.Data(), data_.size()); 87 return UTF8Encoding().Decode(data_.Data(), data_.size());
89 } 88 }
90 89
91 DEFINE_TRACE(PushMessageData) {} 90 DEFINE_TRACE(PushMessageData) {}
92 91
93 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698