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

Side by Side Diff: Source/bindings/v8/custom/V8ArrayBufferCustom.cpp

Issue 18778002: Inherit EventTarget interface instead of duplicating its code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 void V8ArrayBuffer::derefObject(void* object) 65 void V8ArrayBuffer::derefObject(void* object)
66 { 66 {
67 static_cast<ArrayBuffer*>(object)->deref(); 67 static_cast<ArrayBuffer*>(object)->deref();
68 } 68 }
69 69
70 70
71 v8::Handle<v8::Object> V8ArrayBuffer::createWrapper(PassRefPtr<ArrayBuffer> impl , v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 71 v8::Handle<v8::Object> V8ArrayBuffer::createWrapper(PassRefPtr<ArrayBuffer> impl , v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
72 { 72 {
73 ASSERT(impl.get()); 73 ASSERT(impl.get());
74 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); 74 ASSERT(DOMDataStore::getWrapper<V8ArrayBuffer>(impl.get(), isolate).IsEmpty( ));
75 75
76 v8::Handle<v8::Object> wrapper = v8::ArrayBuffer::New(impl->data(), impl->by teLength()); 76 v8::Handle<v8::Object> wrapper = v8::ArrayBuffer::New(impl->data(), impl->by teLength());
77 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength()); 77 v8::V8::AdjustAmountOfExternalAllocatedMemory(impl->byteLength());
78 impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()) ; 78 impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()) ;
79 79
80 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, Wrap perConfiguration::Independent); 80 V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(impl, &info, wrapper , isolate, WrapperConfiguration::Independent);
81 return wrapper; 81 return wrapper;
82 } 82 }
83 83
84 ArrayBuffer* V8ArrayBuffer::toNative(v8::Handle<v8::Object> object) 84 ArrayBuffer* V8ArrayBuffer::toNative(v8::Handle<v8::Object> object)
85 { 85 {
86 ASSERT(object->IsArrayBuffer()); 86 ASSERT(object->IsArrayBuffer());
87 void* arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapp erObjectIndex); 87 void* arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapp erObjectIndex);
88 if (arraybufferPtr) 88 if (arraybufferPtr)
89 return reinterpret_cast<ArrayBuffer*>(arraybufferPtr); 89 return reinterpret_cast<ArrayBuffer*>(arraybufferPtr);
90 90
91 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); 91 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>();
92 ASSERT(!v8buffer->IsExternal()); 92 ASSERT(!v8buffer->IsExternal());
93 93
94 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); 94 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize();
95 ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()); 95 ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength());
96 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(contents); 96 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(contents);
97 // V8 accounts for external memory even after externalizing the buffer. 97 // V8 accounts for external memory even after externalizing the buffer.
98 buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance( )); 98 buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance( ));
99 V8DOMWrapper::associateObjectWithWrapper(buffer.release(), &info, object, v8 ::Isolate::GetCurrent(), WrapperConfiguration::Dependent); 99 V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(buffer.release(), &i nfo, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Dependent);
100 100
101 arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObje ctIndex); 101 arraybufferPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObje ctIndex);
102 ASSERT(arraybufferPtr); 102 ASSERT(arraybufferPtr);
103 return reinterpret_cast<ArrayBuffer*>(arraybufferPtr); 103 return reinterpret_cast<ArrayBuffer*>(arraybufferPtr);
104 } 104 }
105 105
106 106
107 } // namespace WebCore 107 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8ArrayBufferCustom.h ('k') | Source/bindings/v8/custom/V8ArrayBufferViewCustom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698