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

Side by Side Diff: samples/process.cc

Issue 124943004: Prepare removal of ObjectTemplate::New without Isolate parameter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Do not remove ObjectTemplate::New() yet. Created 6 years, 11 months 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 | « samples/lineprocessor.cc ('k') | samples/shell.cc » ('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 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 154
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(GetIsolate());
164 global->Set(String::NewFromUtf8(GetIsolate(), "log"), 164 global->Set(String::NewFromUtf8(GetIsolate(), "log"),
165 FunctionTemplate::New(GetIsolate(), 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);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 // Return the value; any non-empty handle will work. 395 // Return the value; any non-empty handle will work.
396 info.GetReturnValue().Set(value_obj); 396 info.GetReturnValue().Set(value_obj);
397 } 397 }
398 398
399 399
400 Handle<ObjectTemplate> JsHttpRequestProcessor::MakeMapTemplate( 400 Handle<ObjectTemplate> JsHttpRequestProcessor::MakeMapTemplate(
401 Isolate* isolate) { 401 Isolate* isolate) {
402 EscapableHandleScope handle_scope(isolate); 402 EscapableHandleScope handle_scope(isolate);
403 403
404 Local<ObjectTemplate> result = ObjectTemplate::New(); 404 Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
405 result->SetInternalFieldCount(1); 405 result->SetInternalFieldCount(1);
406 result->SetNamedPropertyHandler(MapGet, MapSet); 406 result->SetNamedPropertyHandler(MapGet, MapSet);
407 407
408 // Again, return the result through the current handle scope. 408 // Again, return the result through the current handle scope.
409 return handle_scope.Escape(result); 409 return handle_scope.Escape(result);
410 } 410 }
411 411
412 412
413 // ------------------------------------------- 413 // -------------------------------------------
414 // --- A c c e s s i n g R e q u e s t s --- 414 // --- A c c e s s i n g R e q u e s t s ---
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 info.GetReturnValue().Set(String::NewFromUtf8( 504 info.GetReturnValue().Set(String::NewFromUtf8(
505 info.GetIsolate(), path.c_str(), String::kNormalString, 505 info.GetIsolate(), path.c_str(), String::kNormalString,
506 static_cast<int>(path.length()))); 506 static_cast<int>(path.length())));
507 } 507 }
508 508
509 509
510 Handle<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate( 510 Handle<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate(
511 Isolate* isolate) { 511 Isolate* isolate) {
512 EscapableHandleScope handle_scope(isolate); 512 EscapableHandleScope handle_scope(isolate);
513 513
514 Local<ObjectTemplate> result = ObjectTemplate::New(); 514 Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
515 result->SetInternalFieldCount(1); 515 result->SetInternalFieldCount(1);
516 516
517 // Add accessors for each of the fields of the request. 517 // Add accessors for each of the fields of the request.
518 result->SetAccessor( 518 result->SetAccessor(
519 String::NewFromUtf8(isolate, "path", String::kInternalizedString), 519 String::NewFromUtf8(isolate, "path", String::kInternalizedString),
520 GetPath); 520 GetPath);
521 result->SetAccessor( 521 result->SetAccessor(
522 String::NewFromUtf8(isolate, "referrer", String::kInternalizedString), 522 String::NewFromUtf8(isolate, "referrer", String::kInternalizedString),
523 GetReferrer); 523 GetReferrer);
524 result->SetAccessor( 524 result->SetAccessor(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « samples/lineprocessor.cc ('k') | samples/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698