OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/PrivateScriptRunner.h" | 5 #include "bindings/core/v8/PrivateScriptRunner.h" |
6 | 6 |
7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/core/v8/V8PerContextData.h" | 10 #include "bindings/core/v8/V8PerContextData.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 v8::Local<v8::Context> context = scriptState->context(); | 55 v8::Local<v8::Context> context = scriptState->context(); |
56 v8::Local<v8::Object> global = context->Global(); | 56 v8::Local<v8::Object> global = context->Global(); |
57 v8::Local<v8::Value> privateScriptController = global->Get(context, v8String
(isolate, "privateScriptController")).ToLocalChecked(); | 57 v8::Local<v8::Value> privateScriptController = global->Get(context, v8String
(isolate, "privateScriptController")).ToLocalChecked(); |
58 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro
ller->IsObject()); | 58 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro
ller->IsObject()); |
59 if (privateScriptController->IsObject()) { | 59 if (privateScriptController->IsObject()) { |
60 v8::Local<v8::Object> privateScriptControllerObject = privateScriptContr
oller.As<v8::Object>(); | 60 v8::Local<v8::Object> privateScriptControllerObject = privateScriptContr
oller.As<v8::Object>(); |
61 v8::Local<v8::Value> importFunctionValue = privateScriptControllerObject
->Get(context, v8String(isolate, "import")).ToLocalChecked(); | 61 v8::Local<v8::Value> importFunctionValue = privateScriptControllerObject
->Get(context, v8String(isolate, "import")).ToLocalChecked(); |
62 if (importFunctionValue->IsUndefined()) { | 62 if (importFunctionValue->IsUndefined()) { |
63 v8::Local<v8::Function> function; | 63 v8::Local<v8::Function> function; |
| 64 // This is a memory leak, FunctionTemplates are eternal. |
64 if (!v8::FunctionTemplate::New(isolate, importFunction)->GetFunction
(context).ToLocal(&function) | 65 if (!v8::FunctionTemplate::New(isolate, importFunction)->GetFunction
(context).ToLocal(&function) |
65 || !v8CallBoolean(privateScriptControllerObject->Set(context, v8
String(isolate, "import"), function))) { | 66 || !v8CallBoolean(privateScriptControllerObject->Set(context, v8
String(isolate, "import"), function))) { |
66 fprintf(stderr, "Private script error: Setting import function f
ailed. (Class name = %s)\n", scriptClassName.utf8().data()); | 67 fprintf(stderr, "Private script error: Setting import function f
ailed. (Class name = %s)\n", scriptClassName.utf8().data()); |
67 dumpV8Message(context, block.Message()); | 68 dumpV8Message(context, block.Message()); |
68 RELEASE_NOTREACHED(); | 69 RELEASE_NOTREACHED(); |
69 } | 70 } |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 v8::Local<v8::Script> script; | 74 v8::Local<v8::Script> script; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 v8::Local<v8::Value> result; | 354 v8::Local<v8::Value> result; |
354 if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(method), scr
iptState->getExecutionContext(), holder, argc, argv, scriptState->isolate()).ToL
ocal(&result)) { | 355 if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(method), scr
iptState->getExecutionContext(), holder, argc, argv, scriptState->isolate()).ToL
ocal(&result)) { |
355 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 356 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
356 block.ReThrow(); | 357 block.ReThrow(); |
357 return v8::Local<v8::Value>(); | 358 return v8::Local<v8::Value>(); |
358 } | 359 } |
359 return result; | 360 return result; |
360 } | 361 } |
361 | 362 |
362 } // namespace blink | 363 } // namespace blink |
OLD | NEW |