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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/PrivateScriptRunner.h" | 6 #include "bindings/core/v8/PrivateScriptRunner.h" |
7 | 7 |
8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 v8::Handle<v8::Object> global = isolate->GetCurrentContext()->Global(); | 52 v8::Handle<v8::Object> global = isolate->GetCurrentContext()->Global(); |
53 v8::Handle<v8::Value> privateScriptController = global->Get(v8String(isolate , "privateScriptController")); | 53 v8::Handle<v8::Value> privateScriptController = global->Get(v8String(isolate , "privateScriptController")); |
54 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro ller->IsObject()); | 54 RELEASE_ASSERT(privateScriptController->IsUndefined() || privateScriptContro ller->IsObject()); |
55 if (privateScriptController->IsObject()) { | 55 if (privateScriptController->IsObject()) { |
56 v8::Handle<v8::Object> privateScriptControllerObject = privateScriptCont roller->ToObject(isolate); | 56 v8::Handle<v8::Object> privateScriptControllerObject = privateScriptCont roller->ToObject(isolate); |
57 v8::Handle<v8::Value> importFunctionValue = privateScriptControllerObjec t->Get(v8String(isolate, "import")); | 57 v8::Handle<v8::Value> importFunctionValue = privateScriptControllerObjec t->Get(v8String(isolate, "import")); |
58 if (importFunctionValue->IsUndefined()) | 58 if (importFunctionValue->IsUndefined()) |
59 privateScriptControllerObject->Set(v8String(isolate, "import"), v8:: FunctionTemplate::New(isolate, importFunction)->GetFunction()); | 59 privateScriptControllerObject->Set(v8String(isolate, "import"), v8:: FunctionTemplate::New(isolate, importFunction)->GetFunction()); |
60 } | 60 } |
61 | 61 |
62 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isola te, sourceString), fileName, String(), TextPosition::minimumPosition(), isolate, nullptr, nullptr, nullptr, NotSharableCrossOrigin); | 62 v8::Local<v8::Script> script; |
63 if (block.HasCaught()) { | 63 if (!V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName , String(), TextPosition::minimumPosition(), isolate, nullptr, nullptr, nullptr, NotSharableCrossOrigin).ToLocal(&script)) { |
64 fprintf(stderr, "Private script error: Compile failed. (Class name = %s) \n", scriptClassName.utf8().data()); | 64 fprintf(stderr, "Private script error: Compile failed. (Class name = %s) \n", scriptClassName.utf8().data()); |
65 dumpV8Message(block.Message()); | 65 if (block.HasCaught()) |
haraken
2015/03/13 04:31:16
Just to confirm: When a worker termination is sign
bashi
2015/03/13 05:15:20
I'm not fully confident, but I think you are right
| |
66 dumpV8Message(block.Message()); | |
66 RELEASE_ASSERT_NOT_REACHED(); | 67 RELEASE_ASSERT_NOT_REACHED(); |
67 } | 68 } |
68 | 69 |
69 v8::Handle<v8::Value> result = V8ScriptRunner::runCompiledInternalScript(iso late, script); | 70 v8::Local<v8::Value> result; |
70 if (block.HasCaught()) { | 71 if (!V8ScriptRunner::runCompiledInternalScript(isolate, script).ToLocal(&res ult)) { |
71 fprintf(stderr, "Private script error: installClass() failed. (Class nam e = %s)\n", scriptClassName.utf8().data()); | 72 if (block.HasCaught()) { |
72 dumpV8Message(block.Message()); | 73 fprintf(stderr, "Private script error: installClass() failed. (Class name = %s)\n", scriptClassName.utf8().data()); |
74 dumpV8Message(block.Message()); | |
75 } | |
73 RELEASE_ASSERT_NOT_REACHED(); | 76 RELEASE_ASSERT_NOT_REACHED(); |
74 } | 77 } |
75 return result; | 78 return result; |
76 } | 79 } |
77 | 80 |
78 // Private scripts can use privateScriptController.import(bundledResource, compi leAndRunScript) to import dependent resources. | 81 // Private scripts can use privateScriptController.import(bundledResource, compi leAndRunScript) to import dependent resources. |
79 // |bundledResource| is a string resource name. | 82 // |bundledResource| is a string resource name. |
80 // |compileAndRunScript| optional boolean representing if the javascript should be executed. Default: true. | 83 // |compileAndRunScript| optional boolean representing if the javascript should be executed. Default: true. |
81 void importFunction(const v8::FunctionCallbackInfo<v8::Value>& args) | 84 void importFunction(const v8::FunctionCallbackInfo<v8::Value>& args) |
82 { | 85 { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr iptState->isolate()); | 331 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr iptState->isolate()); |
329 if (block.HasCaught()) { | 332 if (block.HasCaught()) { |
330 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 333 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
331 block.ReThrow(); | 334 block.ReThrow(); |
332 return v8::Handle<v8::Value>(); | 335 return v8::Handle<v8::Value>(); |
333 } | 336 } |
334 return result; | 337 return result; |
335 } | 338 } |
336 | 339 |
337 } // namespace blink | 340 } // namespace blink |
OLD | NEW |