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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h" 6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 27 matching lines...) Expand all
38 // See note in ActiveDOMObject about suspendIfNeeded. 38 // See note in ActiveDOMObject about suspendIfNeeded.
39 characteristic->suspendIfNeeded(); 39 characteristic->suspendIfNeeded();
40 return characteristic; 40 return characteristic;
41 } 41 }
42 42
43 void BluetoothGATTCharacteristic::dispatchCharacteristicValueChanged( 43 void BluetoothGATTCharacteristic::dispatchCharacteristicValueChanged(
44 const WebVector<uint8_t>& value) 44 const WebVector<uint8_t>& value)
45 { 45 {
46 static_assert(sizeof(*value.data()) == 1, "uint8_t should be a single byte") ; 46 static_assert(sizeof(*value.data()) == 1, "uint8_t should be a single byte") ;
47 47
48 m_value = DOMArrayBuffer::create(value.data(), value.size()); 48 // TODO(junov): crbug.com/536816
49 // Should use createOrNull. Requires figuring out a graceful way
50 // to handle allocation failures.
51 m_value = DOMArrayBuffer::deprecatedCreateOrCrash(value.data(), value.size() );
49 52
50 dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged)); 53 dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged));
51 } 54 }
52 55
53 void BluetoothGATTCharacteristic::stop() 56 void BluetoothGATTCharacteristic::stop()
54 { 57 {
55 notifyCharacteristicObjectRemoved(); 58 notifyCharacteristicObjectRemoved();
56 } 59 }
57 60
58 void BluetoothGATTCharacteristic::dispose() 61 void BluetoothGATTCharacteristic::dispose()
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 145 }
143 146
144 DEFINE_TRACE(BluetoothGATTCharacteristic) 147 DEFINE_TRACE(BluetoothGATTCharacteristic)
145 { 148 {
146 RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteris tic>::trace(visitor); 149 RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteris tic>::trace(visitor);
147 ActiveDOMObject::trace(visitor); 150 ActiveDOMObject::trace(visitor);
148 visitor->trace(m_properties); 151 visitor->trace(m_properties);
149 } 152 }
150 153
151 } // namespace blink 154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698