OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // All done; all went well | 213 // All done; all went well |
214 return true; | 214 return true; |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 bool JsHttpRequestProcessor::ExecuteScript(Handle<String> script) { | 218 bool JsHttpRequestProcessor::ExecuteScript(Handle<String> script) { |
219 HandleScope handle_scope(GetIsolate()); | 219 HandleScope handle_scope(GetIsolate()); |
220 | 220 |
221 // We're just about to compile the script; set up an error handler to | 221 // We're just about to compile the script; set up an error handler to |
222 // catch any exceptions the script might throw. | 222 // catch any exceptions the script might throw. |
223 TryCatch try_catch; | 223 TryCatch try_catch(GetIsolate()); |
224 | 224 |
225 // Compile the script and check for errors. | 225 // Compile the script and check for errors. |
226 Handle<Script> compiled_script = Script::Compile(script); | 226 Handle<Script> compiled_script = Script::Compile(script); |
227 if (compiled_script.IsEmpty()) { | 227 if (compiled_script.IsEmpty()) { |
228 String::Utf8Value error(try_catch.Exception()); | 228 String::Utf8Value error(try_catch.Exception()); |
229 Log(*error); | 229 Log(*error); |
230 // The script failed to compile; bail out. | 230 // The script failed to compile; bail out. |
231 return false; | 231 return false; |
232 } | 232 } |
233 | 233 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 v8::Local<v8::Context>::New(GetIsolate(), context_); | 274 v8::Local<v8::Context>::New(GetIsolate(), context_); |
275 | 275 |
276 // Enter this processor's context so all the remaining operations | 276 // Enter this processor's context so all the remaining operations |
277 // take place there | 277 // take place there |
278 Context::Scope context_scope(context); | 278 Context::Scope context_scope(context); |
279 | 279 |
280 // Wrap the C++ request object in a JavaScript wrapper | 280 // Wrap the C++ request object in a JavaScript wrapper |
281 Handle<Object> request_obj = WrapRequest(request); | 281 Handle<Object> request_obj = WrapRequest(request); |
282 | 282 |
283 // Set up an exception handler before calling the Process function | 283 // Set up an exception handler before calling the Process function |
284 TryCatch try_catch; | 284 TryCatch try_catch(GetIsolate()); |
285 | 285 |
286 // Invoke the process function, giving the global object as 'this' | 286 // Invoke the process function, giving the global object as 'this' |
287 // and one argument, the request. | 287 // and one argument, the request. |
288 const int argc = 1; | 288 const int argc = 1; |
289 Handle<Value> argv[argc] = { request_obj }; | 289 Handle<Value> argv[argc] = { request_obj }; |
290 v8::Local<v8::Function> process = | 290 v8::Local<v8::Function> process = |
291 v8::Local<v8::Function>::New(GetIsolate(), process_); | 291 v8::Local<v8::Function>::New(GetIsolate(), process_); |
292 Handle<Value> result = process->Call(context->Global(), argc, argv); | 292 Handle<Value> result = process->Call(context->Global(), argc, argv); |
293 if (result.IsEmpty()) { | 293 if (result.IsEmpty()) { |
294 String::Utf8Value error(try_catch.Exception()); | 294 String::Utf8Value error(try_catch.Exception()); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 JsHttpRequestProcessor processor(isolate, source); | 684 JsHttpRequestProcessor processor(isolate, source); |
685 map<string, string> output; | 685 map<string, string> output; |
686 if (!processor.Initialize(&options, &output)) { | 686 if (!processor.Initialize(&options, &output)) { |
687 fprintf(stderr, "Error initializing processor.\n"); | 687 fprintf(stderr, "Error initializing processor.\n"); |
688 return 1; | 688 return 1; |
689 } | 689 } |
690 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) | 690 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) |
691 return 1; | 691 return 1; |
692 PrintMap(&output); | 692 PrintMap(&output); |
693 } | 693 } |
OLD | NEW |