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

Side by Side Diff: Source/wtf/ArrayBufferContents.h

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 /* 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
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;
haraken 2015/01/21 15:23:33 Do we need m_deallocationObserver? I guess m_deall
sof 2015/01/21 15:51:38 It looks that way; is having a more general interf
haraken 2015/01/21 16:59:17 You can handle this in a follow-up either way :)
Yuki 2015/01/22 04:27:39 m_deallocationObserver must always be **DOM**Array
Yuki 2015/01/22 04:35:20 Additional note: We've made all the DOM objects in
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
OLDNEW
« no previous file with comments | « Source/wtf/ArrayBuffer.h ('k') | Source/wtf/Atomics.h » ('j') | Source/wtf/Threading.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698