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

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

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: update comment, add TODO 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 = 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698