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

Side by Side Diff: Source/core/dom/DOMDataView.cpp

Issue 1178273002: Remove dead DataView IDL and C++ code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DOMDataView.h ('k') | Source/core/dom/DataView.idl » ('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 #include "config.h" 5 #include "config.h"
6 #include "core/dom/DOMDataView.h" 6 #include "core/dom/DOMDataView.h"
7 7
8 #include "bindings/core/v8/DOMDataStore.h" 8 #include "bindings/core/v8/DOMDataStore.h"
9 #include "bindings/core/v8/V8ArrayBuffer.h" 9 #include "bindings/core/v8/V8ArrayBuffer.h"
10 #include "bindings/core/v8/V8DOMWrapper.h" 10 #include "bindings/core/v8/V8DOMWrapper.h"
11 #include "platform/CheckedInt.h"
12 #include "wtf/ArrayBufferView.h"
11 13
12 namespace blink { 14 namespace blink {
13 15
16 namespace {
17
18 class DataView final : public ArrayBufferView {
19 public:
20 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength)
21 {
22 RELEASE_ASSERT(byteOffset <= buffer->byteLength());
23 CheckedInt<uint32_t> checkedOffset(byteOffset);
24 CheckedInt<uint32_t> checkedLength(byteLength);
25 CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength;
26 RELEASE_ASSERT(checkedMax.isValid());
27 RELEASE_ASSERT(checkedMax.value() <= buffer->byteLength());
28 return adoptRef(new DataView(buffer, byteOffset, byteLength));
29 }
30
31 virtual unsigned byteLength() const override { return m_byteLength; }
32 virtual ViewType type() const override { return TypeDataView; }
33
34 protected:
35 virtual void neuter() override
36 {
37 ArrayBufferView::neuter();
38 m_byteLength = 0;
39 }
40
41 private:
42 DataView(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteL ength)
43 : ArrayBufferView(buffer, byteOffset)
44 , m_byteLength(byteLength) { }
45
46 unsigned m_byteLength;
47 };
48
49 } // anonymous namespace
50
14 PassRefPtr<DOMDataView> DOMDataView::create(PassRefPtr<DOMArrayBuffer> prpBuffer , unsigned byteOffset, unsigned byteLength) 51 PassRefPtr<DOMDataView> DOMDataView::create(PassRefPtr<DOMArrayBuffer> prpBuffer , unsigned byteOffset, unsigned byteLength)
15 { 52 {
16 RefPtr<DOMArrayBuffer> buffer = prpBuffer; 53 RefPtr<DOMArrayBuffer> buffer = prpBuffer;
17 RefPtr<DataView> dataView = DataView::create(buffer->buffer(), byteOffset, b yteLength); 54 RefPtr<DataView> dataView = DataView::create(buffer->buffer(), byteOffset, b yteLength);
18 return adoptRef(new DOMDataView(dataView.release(), buffer.release())); 55 return adoptRef(new DOMDataView(dataView.release(), buffer.release()));
19 } 56 }
20 57
21 v8::Local<v8::Object> DOMDataView::wrap(v8::Isolate* isolate, v8::Local<v8::Obje ct> creationContext) 58 v8::Local<v8::Object> DOMDataView::wrap(v8::Isolate* isolate, v8::Local<v8::Obje ct> creationContext)
22 { 59 {
23 // It's possible that no one except for the new wrapper owns this object at 60 // It's possible that no one except for the new wrapper owns this object at
(...skipping 13 matching lines...) Expand all
37 74
38 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); 75 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper);
39 } 76 }
40 77
41 v8::Local<v8::Object> DOMDataView::associateWithWrapper(v8::Isolate* isolate, co nst WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) 78 v8::Local<v8::Object> DOMDataView::associateWithWrapper(v8::Isolate* isolate, co nst WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper)
42 { 79 {
43 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn fo, wrapper); 80 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn fo, wrapper);
44 } 81 }
45 82
46 } // namespace blink 83 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/DOMDataView.h ('k') | Source/core/dom/DataView.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698