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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp

Issue 1535943005: Initial implementation of bindings and basic classes for worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix memory leak. Created 4 years, 12 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) 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/core/v8/V8Binding.h" 32 #include "bindings/core/v8/V8Binding.h"
33 33
34 #include "bindings/core/v8/GlobalScopeScriptController.h"
35 #include "bindings/core/v8/ModuleProxy.h"
34 #include "bindings/core/v8/ScriptController.h" 36 #include "bindings/core/v8/ScriptController.h"
35 #include "bindings/core/v8/V8AbstractEventListener.h" 37 #include "bindings/core/v8/V8AbstractEventListener.h"
36 #include "bindings/core/v8/V8ArrayBufferView.h" 38 #include "bindings/core/v8/V8ArrayBufferView.h"
37 #include "bindings/core/v8/V8BindingMacros.h" 39 #include "bindings/core/v8/V8BindingMacros.h"
38 #include "bindings/core/v8/V8Element.h" 40 #include "bindings/core/v8/V8Element.h"
39 #include "bindings/core/v8/V8EventTarget.h" 41 #include "bindings/core/v8/V8EventTarget.h"
40 #include "bindings/core/v8/V8NodeFilter.h" 42 #include "bindings/core/v8/V8NodeFilter.h"
41 #include "bindings/core/v8/V8NodeFilterCondition.h" 43 #include "bindings/core/v8/V8NodeFilterCondition.h"
42 #include "bindings/core/v8/V8ObjectConstructor.h" 44 #include "bindings/core/v8/V8ObjectConstructor.h"
43 #include "bindings/core/v8/V8Window.h" 45 #include "bindings/core/v8/V8Window.h"
44 #include "bindings/core/v8/V8WorkerGlobalScope.h" 46 #include "bindings/core/v8/V8WorkerGlobalScope.h"
45 #include "bindings/core/v8/V8XPathNSResolver.h" 47 #include "bindings/core/v8/V8XPathNSResolver.h"
46 #include "bindings/core/v8/WindowProxy.h" 48 #include "bindings/core/v8/WindowProxy.h"
47 #include "bindings/core/v8/WorkerScriptController.h"
48 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" 49 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h"
49 #include "core/dom/Document.h" 50 #include "core/dom/Document.h"
50 #include "core/dom/Element.h" 51 #include "core/dom/Element.h"
51 #include "core/dom/FlexibleArrayBufferView.h" 52 #include "core/dom/FlexibleArrayBufferView.h"
52 #include "core/dom/NodeFilter.h" 53 #include "core/dom/NodeFilter.h"
53 #include "core/dom/QualifiedName.h" 54 #include "core/dom/QualifiedName.h"
54 #include "core/frame/LocalDOMWindow.h" 55 #include "core/frame/LocalDOMWindow.h"
55 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
56 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
57 #include "core/inspector/InspectorTraceEvents.h" 58 #include "core/inspector/InspectorTraceEvents.h"
58 #include "core/loader/FrameLoader.h" 59 #include "core/loader/FrameLoader.h"
59 #include "core/loader/FrameLoaderClient.h" 60 #include "core/loader/FrameLoaderClient.h"
60 #include "core/workers/WorkerGlobalScope.h" 61 #include "core/workers/AbstractGlobalScope.h"
61 #include "core/xml/XPathNSResolver.h" 62 #include "core/xml/XPathNSResolver.h"
62 #include "platform/EventTracer.h" 63 #include "platform/EventTracer.h"
63 #include "platform/JSONValues.h" 64 #include "platform/JSONValues.h"
64 #include "wtf/MainThread.h" 65 #include "wtf/MainThread.h"
65 #include "wtf/MathExtras.h" 66 #include "wtf/MathExtras.h"
66 #include "wtf/StdLibExtras.h" 67 #include "wtf/StdLibExtras.h"
67 #include "wtf/Threading.h" 68 #include "wtf/Threading.h"
68 #include "wtf/text/AtomicString.h" 69 #include "wtf/text/AtomicString.h"
69 #include "wtf/text/CString.h" 70 #include "wtf/text/CString.h"
70 #include "wtf/text/CharacterNames.h" 71 #include "wtf/text/CharacterNames.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 { 707 {
707 if (context.IsEmpty()) 708 if (context.IsEmpty())
708 return 0; 709 return 0;
709 v8::Local<v8::Object> global = context->Global(); 710 v8::Local<v8::Object> global = context->Global();
710 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate()); 711 v8::Local<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain (global, context->GetIsolate());
711 if (!windowWrapper.IsEmpty()) 712 if (!windowWrapper.IsEmpty())
712 return V8Window::toImpl(windowWrapper)->executionContext(); 713 return V8Window::toImpl(windowWrapper)->executionContext();
713 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate()); 714 v8::Local<v8::Object> workerWrapper = V8WorkerGlobalScope::findInstanceInPro totypeChain(global, context->GetIsolate());
714 if (!workerWrapper.IsEmpty()) 715 if (!workerWrapper.IsEmpty())
715 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext(); 716 return V8WorkerGlobalScope::toImpl(workerWrapper)->executionContext();
716 // FIXME: Is this line of code reachable? 717 return ModuleProxy::moduleProxy().toExecutionContextForModules(context);
717 return 0;
718 } 718 }
719 719
720 ExecutionContext* currentExecutionContext(v8::Isolate* isolate) 720 ExecutionContext* currentExecutionContext(v8::Isolate* isolate)
721 { 721 {
722 return toExecutionContext(isolate->GetCurrentContext()); 722 return toExecutionContext(isolate->GetCurrentContext());
723 } 723 }
724 724
725 ExecutionContext* callingExecutionContext(v8::Isolate* isolate) 725 ExecutionContext* callingExecutionContext(v8::Isolate* isolate)
726 { 726 {
727 v8::Local<v8::Context> context = isolate->GetCallingContext(); 727 v8::Local<v8::Context> context = isolate->GetCallingContext();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 buffer->CopyContents(storage, length); 770 buffer->CopyContents(storage, length);
771 result.setSmall(storage, length); 771 result.setSmall(storage, length);
772 } 772 }
773 773
774 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld) 774 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w orld)
775 { 775 {
776 ASSERT(context); 776 ASSERT(context);
777 if (context->isDocument()) { 777 if (context->isDocument()) {
778 if (LocalFrame* frame = toDocument(context)->frame()) 778 if (LocalFrame* frame = toDocument(context)->frame())
779 return toV8Context(frame, world); 779 return toV8Context(frame, world);
780 } else if (context->isWorkerGlobalScope()) { 780 } else if (context->isWorkerGlobalScope()) {
kinuko 2015/12/22 08:39:03 nit: isAbstractGlobalScope() ?
ikilpatrick 2015/12/22 23:40:23 Done.
781 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip t()) { 781 if (GlobalScopeScriptController* script = toAbstractGlobalScope(context) ->script()) {
782 if (script->scriptState()->contextIsValid()) 782 if (script->scriptState()->contextIsValid())
783 return script->scriptState()->context(); 783 return script->scriptState()->context();
784 } 784 }
785 } 785 }
786 return v8::Local<v8::Context>(); 786 return v8::Local<v8::Context>();
787 } 787 }
788 788
789 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world) 789 v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world)
790 { 790 {
791 if (!frame) 791 if (!frame)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 v8::Local<v8::Value> data = info.Data(); 1019 v8::Local<v8::Value> data = info.Data();
1020 ASSERT(data->IsExternal()); 1020 ASSERT(data->IsExternal());
1021 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext()); 1021 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre ationContext());
1022 if (!perContextData) 1022 if (!perContextData)
1023 return; 1023 return;
1024 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 1024 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
1025 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 1025 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
1026 } 1026 }
1027 1027
1028 } // namespace blink 1028 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698