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

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

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: remove unused checks 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/PushSubscriptionOptions.h" 5 #include "modules/push_messaging/PushSubscriptionOptions.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/dom/DOMArrayBuffer.h" 8 #include "core/dom/DOMArrayBuffer.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 #include "modules/push_messaging/PushSubscriptionOptionsInit.h" 10 #include "modules/push_messaging/PushSubscriptionOptionsInit.h"
(...skipping 13 matching lines...) Expand all
24 ExceptionState& exceptionState) { 24 ExceptionState& exceptionState) {
25 unsigned char* input; 25 unsigned char* input;
26 int length; 26 int length;
27 // Convert the input array into a string of bytes. 27 // Convert the input array into a string of bytes.
28 if (applicationServerKey.isArrayBuffer()) { 28 if (applicationServerKey.isArrayBuffer()) {
29 input = static_cast<unsigned char*>( 29 input = static_cast<unsigned char*>(
30 applicationServerKey.getAsArrayBuffer()->data()); 30 applicationServerKey.getAsArrayBuffer()->data());
31 length = applicationServerKey.getAsArrayBuffer()->byteLength(); 31 length = applicationServerKey.getAsArrayBuffer()->byteLength();
32 } else if (applicationServerKey.isArrayBufferView()) { 32 } else if (applicationServerKey.isArrayBufferView()) {
33 input = static_cast<unsigned char*>( 33 input = static_cast<unsigned char*>(
34 applicationServerKey.getAsArrayBufferView()->buffer()->data()); 34 applicationServerKey.getAsArrayBufferView().view()->buffer()->data());
35 length = 35 length = applicationServerKey.getAsArrayBufferView()
36 applicationServerKey.getAsArrayBufferView()->buffer()->byteLength(); 36 .view()
37 ->buffer()
38 ->byteLength();
37 } else { 39 } else {
38 NOTREACHED(); 40 NOTREACHED();
39 return String(); 41 return String();
40 } 42 }
41 43
42 // Check the validity of the sender info. It must either be a 65-byte 44 // Check the validity of the sender info. It must either be a 65-byte
43 // uncompressed VAPID key, which has the byte 0x04 as the first byte or a 45 // uncompressed VAPID key, which has the byte 0x04 as the first byte or a
44 // numeric sender ID. 46 // numeric sender ID.
45 const bool isVapid = length == 65 && *input == 0x04; 47 const bool isVapid = length == 65 && *input == 0x04;
46 const bool isSenderId = 48 const bool isSenderId =
(...skipping 28 matching lines...) Expand all
75 : m_userVisibleOnly(options.userVisibleOnly), 77 : m_userVisibleOnly(options.userVisibleOnly),
76 m_applicationServerKey( 78 m_applicationServerKey(
77 DOMArrayBuffer::create(options.applicationServerKey.latin1().data(), 79 DOMArrayBuffer::create(options.applicationServerKey.latin1().data(),
78 options.applicationServerKey.length())) {} 80 options.applicationServerKey.length())) {}
79 81
80 DEFINE_TRACE(PushSubscriptionOptions) { 82 DEFINE_TRACE(PushSubscriptionOptions) {
81 visitor->trace(m_applicationServerKey); 83 visitor->trace(m_applicationServerKey);
82 } 84 }
83 85
84 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698