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

Side by Side Diff: gin/runner.cc

Issue 114883003: Implement more of the JavaScript GL API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 7 years 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 | « gin/modules/file_module_provider.cc ('k') | mojo/apps/js/bindings/codec.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gin/runner.h" 5 #include "gin/runner.h"
6 6
7 #include "gin/converter.h" 7 #include "gin/converter.h"
8 #include "gin/per_context_data.h" 8 #include "gin/per_context_data.h"
9 #include "gin/try_catch.h" 9 #include "gin/try_catch.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 PerContextData::From(context)->set_runner(this); 52 PerContextData::From(context)->set_runner(this);
53 53
54 v8::Context::Scope scope(context); 54 v8::Context::Scope scope(context);
55 delegate_->DidCreateContext(this); 55 delegate_->DidCreateContext(this);
56 } 56 }
57 57
58 Runner::~Runner() { 58 Runner::~Runner() {
59 } 59 }
60 60
61 void Runner::Run(const std::string& source, const std::string& resource_name) { 61 void Runner::Run(const std::string& source, const std::string& resource_name) {
62 Run(Script::New(StringToV8(isolate(), source), 62 TryCatch try_catch;
63 StringToV8(isolate(), resource_name))); 63 v8::Handle<Script> script = Script::New(StringToV8(isolate(), source),
64 StringToV8(isolate(), resource_name));
65 if (try_catch.HasCaught()) {
66 delegate_->UnhandledException(this, try_catch);
67 return;
68 }
69
70 Run(script);
64 } 71 }
65 72
66 void Runner::Run(v8::Handle<Script> script) { 73 void Runner::Run(v8::Handle<Script> script) {
67 TryCatch try_catch; 74 TryCatch try_catch;
68 delegate_->WillRunScript(this); 75 delegate_->WillRunScript(this);
69 76
70 script->Run(); 77 script->Run();
71 78
72 delegate_->DidRunScript(this); 79 delegate_->DidRunScript(this);
73 if (try_catch.HasCaught()) 80 if (try_catch.HasCaught())
74 delegate_->UnhandledException(this, try_catch); 81 delegate_->UnhandledException(this, try_catch);
75 } 82 }
76 83
77 v8::Handle<v8::Value> Runner::Call(v8::Handle<v8::Function> function, 84 v8::Handle<v8::Value> Runner::Call(v8::Handle<v8::Function> function,
78 v8::Handle<v8::Value> receiver, 85 v8::Handle<v8::Value> receiver,
79 int argc, 86 int argc,
80 v8::Handle<v8::Value> argv[]) { 87 v8::Handle<v8::Value> argv[]) {
81 TryCatch try_catch; 88 TryCatch try_catch;
82 delegate_->WillRunScript(this); 89 delegate_->WillRunScript(this);
83 90
84 v8::Handle<v8::Value> result = function->Call(receiver, argc, argv); 91 v8::Handle<v8::Value> result = function->Call(receiver, argc, argv);
85 92
86 delegate_->DidRunScript(this); 93 delegate_->DidRunScript(this);
87 if (try_catch.HasCaught()) 94 if (try_catch.HasCaught()) {
88 delegate_->UnhandledException(this, try_catch); 95 delegate_->UnhandledException(this, try_catch);
96 }
89 97
90 return result; 98 return result;
91 } 99 }
92 100
93 Runner::Scope::Scope(Runner* runner) 101 Runner::Scope::Scope(Runner* runner)
94 : isolate_scope_(runner->isolate()), 102 : isolate_scope_(runner->isolate()),
95 handle_scope_(runner->isolate()), 103 handle_scope_(runner->isolate()),
96 scope_(runner->context()) { 104 scope_(runner->context()) {
97 } 105 }
98 106
99 Runner::Scope::~Scope() { 107 Runner::Scope::~Scope() {
100 } 108 }
101 109
102 } // namespace gin 110 } // namespace gin
OLDNEW
« no previous file with comments | « gin/modules/file_module_provider.cc ('k') | mojo/apps/js/bindings/codec.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698