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

Side by Side Diff: Source/bindings/v8/V8Binding.cpp

Issue 18316003: Revert "Use V8 implementation of ArrayBuffer in Blink." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | Source/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/dom/NodeFilter.h" 47 #include "core/dom/NodeFilter.h"
48 #include "core/dom/QualifiedName.h" 48 #include "core/dom/QualifiedName.h"
49 #include "core/dom/WebCoreMemoryInstrumentation.h" 49 #include "core/dom/WebCoreMemoryInstrumentation.h"
50 #include "core/inspector/BindingVisitors.h" 50 #include "core/inspector/BindingVisitors.h"
51 #include "core/loader/FrameLoader.h" 51 #include "core/loader/FrameLoader.h"
52 #include "core/loader/FrameLoaderClient.h" 52 #include "core/loader/FrameLoaderClient.h"
53 #include "core/page/Frame.h" 53 #include "core/page/Frame.h"
54 #include "core/page/Settings.h" 54 #include "core/page/Settings.h"
55 #include "core/workers/WorkerGlobalScope.h" 55 #include "core/workers/WorkerGlobalScope.h"
56 #include "core/xml/XPathNSResolver.h" 56 #include "core/xml/XPathNSResolver.h"
57 #include "wtf/ArrayBufferContents.h"
58 #include "wtf/MainThread.h" 57 #include "wtf/MainThread.h"
59 #include "wtf/MathExtras.h" 58 #include "wtf/MathExtras.h"
60 #include "wtf/StdLibExtras.h" 59 #include "wtf/StdLibExtras.h"
61 #include "wtf/Threading.h" 60 #include "wtf/Threading.h"
62 #include "wtf/text/AtomicString.h" 61 #include "wtf/text/AtomicString.h"
63 #include "wtf/text/CString.h" 62 #include "wtf/text/CString.h"
64 #include "wtf/text/StringBuffer.h" 63 #include "wtf/text/StringBuffer.h"
65 #include "wtf/text/StringHash.h" 64 #include "wtf/text/StringHash.h"
66 #include "wtf/text/WTFString.h" 65 #include "wtf/text/WTFString.h"
67 66
(...skipping 17 matching lines...) Expand all
85 v8::Handle<v8::Value> throwTypeError(const char* message, v8::Isolate* isolate) 84 v8::Handle<v8::Value> throwTypeError(const char* message, v8::Isolate* isolate)
86 { 85 {
87 return V8ThrowException::throwTypeError(message, isolate); 86 return V8ThrowException::throwTypeError(message, isolate);
88 } 87 }
89 88
90 v8::Handle<v8::Value> throwNotEnoughArgumentsError(v8::Isolate* isolate) 89 v8::Handle<v8::Value> throwNotEnoughArgumentsError(v8::Isolate* isolate)
91 { 90 {
92 return V8ThrowException::throwNotEnoughArgumentsError(isolate); 91 return V8ThrowException::throwNotEnoughArgumentsError(isolate);
93 } 92 }
94 93
95 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
96 virtual void* Allocate(size_t size) OVERRIDE
97 {
98 void* data;
99 if (WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferConte nts::ZeroInitialize, data))
100 return data;
101 return 0;
102 }
103
104 virtual void Free(void* data) OVERRIDE
105 {
106 WTF::ArrayBufferContents::freeMemory(data);
107 }
108 };
109
110 v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator()
111 {
112 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ());
113 return &arrayBufferAllocator;
114 }
115
116
117 v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList> stringList, v8::Isolate* isolate) 94 v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList> stringList, v8::Isolate* isolate)
118 { 95 {
119 if (!stringList) 96 if (!stringList)
120 return v8::Array::New(); 97 return v8::Array::New();
121 v8::Local<v8::Array> result = v8::Array::New(stringList->length()); 98 v8::Local<v8::Array> result = v8::Array::New(stringList->length());
122 for (unsigned i = 0; i < stringList->length(); ++i) 99 for (unsigned i = 0; i < stringList->length(); ++i)
123 result->Set(v8::Integer::New(i, isolate), v8String(stringList->item(i), isolate)); 100 result->Set(v8::Integer::New(i, isolate), v8String(stringList->item(i), isolate));
124 return result; 101 return result;
125 } 102 }
126 103
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 514 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
538 if (data->workerDOMDataStore()) 515 if (data->workerDOMDataStore())
539 return 0; 516 return 0;
540 if (!DOMWrapperWorld::isolatedWorldsExist()) 517 if (!DOMWrapperWorld::isolatedWorldsExist())
541 return 0; 518 return 0;
542 ASSERT(!v8::Context::GetEntered().IsEmpty()); 519 ASSERT(!v8::Context::GetEntered().IsEmpty());
543 return DOMWrapperWorld::isolatedWorld(v8::Context::GetEntered()); 520 return DOMWrapperWorld::isolatedWorld(v8::Context::GetEntered());
544 } 521 }
545 522
546 } // namespace WebCore 523 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | Source/bindings/v8/V8Utilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698