Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / DOMArrayBufferDeallocationObserver.cpp
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/dom/DOMArrayBufferDeallocationObserver.h"
7
8 #include "wtf/Threading.h"
9 #include <v8.h>
10
11 namespace blink {
12
13 DOMArrayBufferDeallocationObserver* DOMArrayBufferDeallocationObserver::instance()
14 {
15     AtomicallyInitializedStatic(
16         DOMArrayBufferDeallocationObserver*,
17         deallocationObserver = new DOMArrayBufferDeallocationObserver);
18     return deallocationObserver;
19 }
20
21 void DOMArrayBufferDeallocationObserver::arrayBufferDeallocated(unsigned sizeInBytes)
22 {
23     v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-static_cast<int>(sizeInBytes));
24 }
25
26 void DOMArrayBufferDeallocationObserver::blinkAllocatedMemory(unsigned sizeInBytes)
27 {
28     v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(static_cast<int>(sizeInBytes));
29 }
30
31 } // namespace blink