OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // of the caller to make sure JS knows about external memory. | 51 // of the caller to make sure JS knows about external memory. |
52 ArrayBufferContents(void* data, unsigned sizeInBytes, ArrayBufferDeallocatio
nObserver*); | 52 ArrayBufferContents(void* data, unsigned sizeInBytes, ArrayBufferDeallocatio
nObserver*); |
53 | 53 |
54 ~ArrayBufferContents(); | 54 ~ArrayBufferContents(); |
55 | 55 |
56 void clear(); | 56 void clear(); |
57 | 57 |
58 void* data() const { return m_data; } | 58 void* data() const { return m_data; } |
59 unsigned sizeInBytes() const { return m_sizeInBytes; } | 59 unsigned sizeInBytes() const { return m_sizeInBytes; } |
60 | 60 |
61 void setDeallocationObserver(ArrayBufferDeallocationObserver* observer) | 61 void setDeallocationObserver(ArrayBufferDeallocationObserver& observer) |
62 { | 62 { |
63 if (!m_deallocationObserver) { | 63 if (!m_deallocationObserver) { |
64 m_deallocationObserver = observer; | 64 m_deallocationObserver = &observer; |
65 m_deallocationObserver->blinkAllocatedMemory(m_sizeInBytes); | 65 m_deallocationObserver->blinkAllocatedMemory(m_sizeInBytes); |
66 } | 66 } |
67 } | 67 } |
68 void setDeallocationObserverWithoutAllocationNotification(ArrayBufferDealloc
ationObserver* observer) | 68 void setDeallocationObserverWithoutAllocationNotification(ArrayBufferDealloc
ationObserver& observer) |
69 { | 69 { |
70 if (!m_deallocationObserver) { | 70 if (!m_deallocationObserver) { |
71 m_deallocationObserver = observer; | 71 m_deallocationObserver = &observer; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 void transfer(ArrayBufferContents& other); | 75 void transfer(ArrayBufferContents& other); |
76 void copyTo(ArrayBufferContents& other); | 76 void copyTo(ArrayBufferContents& other); |
77 | 77 |
78 static void allocateMemory(size_t, InitializationPolicy, void*&); | 78 static void allocateMemory(size_t, InitializationPolicy, void*&); |
79 static void freeMemory(void*, size_t); | 79 static void freeMemory(void*, size_t); |
80 | 80 |
81 private: | 81 private: |
82 void* m_data; | 82 void* m_data; |
83 unsigned m_sizeInBytes; | 83 unsigned m_sizeInBytes; |
84 ArrayBufferDeallocationObserver* m_deallocationObserver; | 84 ArrayBufferDeallocationObserver* m_deallocationObserver; |
85 }; | 85 }; |
86 | 86 |
87 } // namespace WTF | 87 } // namespace WTF |
88 | 88 |
89 #endif // ArrayBufferContents_h | 89 #endif // ArrayBufferContents_h |
OLD | NEW |