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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h

Issue 2321713002: Add a static_cast to fix a bug in ScriptValueSerializer::doReadUint64. (Closed)
Patch Set: align the buffer, because there is an assertion that demands it Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef ScriptValueSerializer_h 5 #ifndef ScriptValueSerializer_h
6 #define ScriptValueSerializer_h 6 #define ScriptValueSerializer_h
7 7
8 #include "base/gtest_prod_util.h"
8 #include "bindings/core/v8/SerializationTag.h" 9 #include "bindings/core/v8/SerializationTag.h"
9 #include "bindings/core/v8/SerializedScriptValue.h" 10 #include "bindings/core/v8/SerializedScriptValue.h"
10 #include "bindings/core/v8/V8Binding.h" 11 #include "bindings/core/v8/V8Binding.h"
11 #include "core/CoreExport.h" 12 #include "core/CoreExport.h"
12 #include "wtf/HashMap.h" 13 #include "wtf/HashMap.h"
13 #include "wtf/Noncopyable.h" 14 #include "wtf/Noncopyable.h"
14 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
15 #include "wtf/text/WTFString.h" 16 #include "wtf/text/WTFString.h"
16 #include "wtf/typed_arrays/ArrayBufferContents.h" 17 #include "wtf/typed_arrays/ArrayBufferContents.h"
17 #include <v8.h> 18 #include <v8.h>
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 template<class T> 534 template<class T>
534 bool doReadUintHelper(T* value) 535 bool doReadUintHelper(T* value)
535 { 536 {
536 *value = 0; 537 *value = 0;
537 uint8_t currentByte; 538 uint8_t currentByte;
538 int shift = 0; 539 int shift = 0;
539 do { 540 do {
540 if (m_position >= m_length) 541 if (m_position >= m_length)
541 return false; 542 return false;
542 currentByte = m_buffer[m_position++]; 543 currentByte = m_buffer[m_position++];
543 *value |= ((currentByte & SerializedScriptValue::varIntMask) << shif t); 544 *value |= (static_cast<T>(currentByte & SerializedScriptValue::varIn tMask) << shift);
544 shift += SerializedScriptValue::varIntShift; 545 shift += SerializedScriptValue::varIntShift;
545 } while (currentByte & (1 << SerializedScriptValue::varIntShift)); 546 } while (currentByte & (1 << SerializedScriptValue::varIntShift));
546 return true; 547 return true;
547 } 548 }
548 549
549 bool doReadUint64(uint64_t* value); 550 bool doReadUint64(uint64_t* value);
550 bool doReadNumber(double* number); 551 bool doReadNumber(double* number);
551 PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, con st String& type, long long size = -1); 552 PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, con st String& type, long long size = -1);
552 553
553 RefPtr<ScriptState> m_scriptState; 554 RefPtr<ScriptState> m_scriptState;
554 const uint8_t* m_buffer; 555 const uint8_t* m_buffer;
555 const unsigned m_length; 556 const unsigned m_length;
556 unsigned m_position; 557 unsigned m_position;
557 uint32_t m_version; 558 uint32_t m_version;
558 const WebBlobInfoArray* m_blobInfo; 559 const WebBlobInfoArray* m_blobInfo;
559 const BlobDataHandleMap& m_blobDataHandles; 560 const BlobDataHandleMap& m_blobDataHandles;
561
562 FRIEND_TEST_ALL_PREFIXES(ScriptValueSerializerTest, Uint64Decode);
560 }; 563 };
561 564
562 class CORE_EXPORT ScriptValueDeserializer { 565 class CORE_EXPORT ScriptValueDeserializer {
563 STACK_ALLOCATED(); 566 STACK_ALLOCATED();
564 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializer); 567 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializer);
565 public: 568 public:
566 ScriptValueDeserializer(SerializedScriptValueReader& reader, MessagePortArra y* messagePorts, ArrayBufferContentsArray* arrayBufferContents, ImageBitmapConte ntsArray* imageBitmapContents) 569 ScriptValueDeserializer(SerializedScriptValueReader& reader, MessagePortArra y* messagePorts, ArrayBufferContentsArray* arrayBufferContents, ImageBitmapConte ntsArray* imageBitmapContents)
567 : m_reader(reader) 570 : m_reader(reader)
568 , m_transferredMessagePorts(messagePorts) 571 , m_transferredMessagePorts(messagePorts)
569 , m_arrayBufferContents(arrayBufferContents) 572 , m_arrayBufferContents(arrayBufferContents)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 ArrayBufferContentsArray* m_arrayBufferContents; 625 ArrayBufferContentsArray* m_arrayBufferContents;
623 ImageBitmapContentsArray* m_imageBitmapContents; 626 ImageBitmapContentsArray* m_imageBitmapContents;
624 Vector<v8::Local<v8::Value>> m_arrayBuffers; 627 Vector<v8::Local<v8::Value>> m_arrayBuffers;
625 Vector<v8::Local<v8::Value>> m_imageBitmaps; 628 Vector<v8::Local<v8::Value>> m_imageBitmaps;
626 uint32_t m_version; 629 uint32_t m_version;
627 }; 630 };
628 631
629 } // namespace blink 632 } // namespace blink
630 633
631 #endif // ScriptValueSerializer_h 634 #endif // ScriptValueSerializer_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698