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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Execute the script and fetch the Process method. | 155 // Execute the script and fetch the Process method. |
156 bool JsHttpRequestProcessor::Initialize(map<string, string>* opts, | 156 bool JsHttpRequestProcessor::Initialize(map<string, string>* opts, |
157 map<string, string>* output) { | 157 map<string, string>* output) { |
158 // Create a handle scope to hold the temporary references. | 158 // Create a handle scope to hold the temporary references. |
159 HandleScope handle_scope(GetIsolate()); | 159 HandleScope handle_scope(GetIsolate()); |
160 | 160 |
161 // Create a template for the global object where we set the | 161 // Create a template for the global object where we set the |
162 // built-in global functions. | 162 // built-in global functions. |
163 Handle<ObjectTemplate> global = ObjectTemplate::New(); | 163 Handle<ObjectTemplate> global = ObjectTemplate::New(); |
164 global->Set(String::NewFromUtf8(GetIsolate(), "log"), | 164 global->Set(String::NewFromUtf8(GetIsolate(), "log"), |
165 FunctionTemplate::New(LogCallback)); | 165 FunctionTemplate::New(GetIsolate(), LogCallback)); |
166 | 166 |
167 // Each processor gets its own context so different processors don't | 167 // Each processor gets its own context so different processors don't |
168 // affect each other. Context::New returns a persistent handle which | 168 // affect each other. Context::New returns a persistent handle which |
169 // is what we need for the reference to remain after we return from | 169 // is what we need for the reference to remain after we return from |
170 // this method. That persistent handle has to be disposed in the | 170 // this method. That persistent handle has to be disposed in the |
171 // destructor. | 171 // destructor. |
172 v8::Handle<v8::Context> context = Context::New(GetIsolate(), NULL, global); | 172 v8::Handle<v8::Context> context = Context::New(GetIsolate(), NULL, global); |
173 context_.Reset(GetIsolate(), context); | 173 context_.Reset(GetIsolate(), context); |
174 | 174 |
175 // Enter the new context so all the following operations take place | 175 // Enter the new context so all the following operations take place |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 JsHttpRequestProcessor processor(isolate, source); | 661 JsHttpRequestProcessor processor(isolate, source); |
662 map<string, string> output; | 662 map<string, string> output; |
663 if (!processor.Initialize(&options, &output)) { | 663 if (!processor.Initialize(&options, &output)) { |
664 fprintf(stderr, "Error initializing processor.\n"); | 664 fprintf(stderr, "Error initializing processor.\n"); |
665 return 1; | 665 return 1; |
666 } | 666 } |
667 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) | 667 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) |
668 return 1; | 668 return 1; |
669 PrintMap(&output); | 669 PrintMap(&output); |
670 } | 670 } |
OLD | NEW |