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

Side by Side Diff: third_party/WebKit/Source/core/dom/FlexibleArrayBufferView.h

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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 #ifndef FlexibleArrayBufferView_h 5 #ifndef FlexibleArrayBufferView_h
6 #define FlexibleArrayBufferView_h 6 #define FlexibleArrayBufferView_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/dom/DOMArrayBufferView.h" 9 #include "core/dom/DOMArrayBufferView.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 24 matching lines...) Expand all
35 m_smallData = nullptr; 35 m_smallData = nullptr;
36 m_smallLength = 0; 36 m_smallLength = 0;
37 } 37 }
38 38
39 bool isEmpty() const { return !m_full && !m_smallData; } 39 bool isEmpty() const { return !m_full && !m_smallData; }
40 bool isFull() const { return m_full; } 40 bool isFull() const { return m_full; }
41 41
42 DOMArrayBufferView* full() const 42 DOMArrayBufferView* full() const
43 { 43 {
44 DCHECK(isFull()); 44 DCHECK(isFull());
45 return m_full; 45 return m_full.get();
46 } 46 }
47 47
48 // WARNING: The pointer returned by baseAddressMaybeOnStack() may point to 48 // WARNING: The pointer returned by baseAddressMaybeOnStack() may point to
49 // temporary storage that is only valid during the life-time of the 49 // temporary storage that is only valid during the life-time of the
50 // FlexibleArrayBufferView object. 50 // FlexibleArrayBufferView object.
51 void* baseAddressMaybeOnStack() const 51 void* baseAddressMaybeOnStack() const
52 { 52 {
53 DCHECK(!isEmpty()); 53 DCHECK(!isEmpty());
54 return isFull() ? m_full->baseAddress() : m_smallData; 54 return isFull() ? m_full->baseAddress() : m_smallData;
55 } 55 }
56 56
57 unsigned byteOffset() const 57 unsigned byteOffset() const
58 { 58 {
59 DCHECK(!isEmpty()); 59 DCHECK(!isEmpty());
60 return isFull() ? m_full->byteOffset() : 0; 60 return isFull() ? m_full->byteOffset() : 0;
61 } 61 }
62 62
63 unsigned byteLength() const 63 unsigned byteLength() const
64 { 64 {
65 DCHECK(!isEmpty()); 65 DCHECK(!isEmpty());
66 return isFull() ? m_full->byteLength() : m_smallLength; 66 return isFull() ? m_full->byteLength() : m_smallLength;
67 } 67 }
68 68
69 operator bool() const { return !isEmpty(); } 69 operator bool() const { return !isEmpty(); }
70 70
71 private: 71 private:
72 Member<DOMArrayBufferView> m_full; 72 RefPtr<DOMArrayBufferView> m_full;
73 73
74 void* m_smallData; 74 void* m_smallData;
75 size_t m_smallLength; 75 size_t m_smallLength;
76 }; 76 };
77 77
78 } // namespace blink 78 } // namespace blink
79 79
80 #endif // FlexibleArrayBufferView_h 80 #endif // FlexibleArrayBufferView_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DataView.idl ('k') | third_party/WebKit/Source/core/dom/SharedArrayBuffer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698