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

Side by Side Diff: net/proxy/proxy_resolver_v8.cc

Issue 14746011: Use Persistent::Reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code review (jochen) Created 7 years, 7 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 | « chrome/renderer/extensions/scoped_persistent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/proxy/proxy_resolver_v8.h" 5 #include "net/proxy/proxy_resolver_v8.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdio> 8 #include <cstdio>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 397 }
398 398
399 results->UsePacString(UTF16ToASCII(ret_str)); 399 results->UsePacString(UTF16ToASCII(ret_str));
400 return OK; 400 return OK;
401 } 401 }
402 402
403 int InitV8(const scoped_refptr<ProxyResolverScriptData>& pac_script) { 403 int InitV8(const scoped_refptr<ProxyResolverScriptData>& pac_script) {
404 v8::Locker locked(isolate_); 404 v8::Locker locked(isolate_);
405 v8::HandleScope scope; 405 v8::HandleScope scope;
406 406
407 v8_this_ = v8::Persistent<v8::External>::New(isolate_, 407 v8_this_.Reset(isolate_, v8::External::New(this));
408 v8::External::New(this));
409 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 408 v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
410 409
411 // Attach the javascript bindings. 410 // Attach the javascript bindings.
412 v8::Local<v8::FunctionTemplate> alert_template = 411 v8::Local<v8::FunctionTemplate> alert_template =
413 v8::FunctionTemplate::New(&AlertCallback, v8_this_); 412 v8::FunctionTemplate::New(&AlertCallback, v8_this_);
414 global_template->Set(ASCIILiteralToV8String("alert"), alert_template); 413 global_template->Set(ASCIILiteralToV8String("alert"), alert_template);
415 414
416 v8::Local<v8::FunctionTemplate> my_ip_address_template = 415 v8::Local<v8::FunctionTemplate> my_ip_address_template =
417 v8::FunctionTemplate::New(&MyIpAddressCallback, v8_this_); 416 v8::FunctionTemplate::New(&MyIpAddressCallback, v8_this_);
418 global_template->Set(ASCIILiteralToV8String("myIpAddress"), 417 global_template->Set(ASCIILiteralToV8String("myIpAddress"),
(...skipping 19 matching lines...) Expand all
438 v8::Local<v8::FunctionTemplate> sort_ip_address_list_template = 437 v8::Local<v8::FunctionTemplate> sort_ip_address_list_template =
439 v8::FunctionTemplate::New(&SortIpAddressListCallback, v8_this_); 438 v8::FunctionTemplate::New(&SortIpAddressListCallback, v8_this_);
440 global_template->Set(ASCIILiteralToV8String("sortIpAddressList"), 439 global_template->Set(ASCIILiteralToV8String("sortIpAddressList"),
441 sort_ip_address_list_template); 440 sort_ip_address_list_template);
442 441
443 v8::Local<v8::FunctionTemplate> is_in_net_ex_template = 442 v8::Local<v8::FunctionTemplate> is_in_net_ex_template =
444 v8::FunctionTemplate::New(&IsInNetExCallback, v8_this_); 443 v8::FunctionTemplate::New(&IsInNetExCallback, v8_this_);
445 global_template->Set(ASCIILiteralToV8String("isInNetEx"), 444 global_template->Set(ASCIILiteralToV8String("isInNetEx"),
446 is_in_net_ex_template); 445 is_in_net_ex_template);
447 446
448 v8_context_ = v8::Persistent<v8::Context>::New( 447 v8_context_.Reset(
449 isolate_, v8::Context::New(isolate_, NULL, global_template)); 448 isolate_, v8::Context::New(isolate_, NULL, global_template));
450 449
451 v8::Context::Scope ctx(v8_context_); 450 v8::Context::Scope ctx(v8_context_);
452 451
453 // Add the PAC utility functions to the environment. 452 // Add the PAC utility functions to the environment.
454 // (This script should never fail, as it is a string literal!) 453 // (This script should never fail, as it is a string literal!)
455 // Note that the two string literals are concatenated. 454 // Note that the two string literals are concatenated.
456 int rv = RunScript( 455 int rv = RunScript(
457 ASCIILiteralToV8String( 456 ASCIILiteralToV8String(
458 PROXY_RESOLVER_SCRIPT 457 PROXY_RESOLVER_SCRIPT
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 if (!g_default_isolate_) 752 if (!g_default_isolate_)
754 return 0; 753 return 0;
755 754
756 v8::Locker locked(g_default_isolate_); 755 v8::Locker locked(g_default_isolate_);
757 v8::HeapStatistics heap_statistics; 756 v8::HeapStatistics heap_statistics;
758 g_default_isolate_->GetHeapStatistics(&heap_statistics); 757 g_default_isolate_->GetHeapStatistics(&heap_statistics);
759 return heap_statistics.used_heap_size(); 758 return heap_statistics.used_heap_size();
760 } 759 }
761 760
762 } // namespace net 761 } // namespace net
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/scoped_persistent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698