| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 return UTF8StdStringToV8String(ip_address_list); | 406 return UTF8StdStringToV8String(ip_address_list); |
| 407 } | 407 } |
| 408 | 408 |
| 409 // V8 callback for when "dnsResolve()" is invoked by the PAC script. | 409 // V8 callback for when "dnsResolve()" is invoked by the PAC script. |
| 410 static v8::Handle<v8::Value> DnsResolveCallback(const v8::Arguments& args) { | 410 static v8::Handle<v8::Value> DnsResolveCallback(const v8::Arguments& args) { |
| 411 Context* context = | 411 Context* context = |
| 412 static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); | 412 static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); |
| 413 | 413 |
| 414 // We need at least one string argument. | 414 // We need at least one string argument. |
| 415 std::string hostname; | 415 std::string hostname; |
| 416 if (!GetHostnameArgument(args, &hostname)) | 416 if (!GetHostnameArgument(args, &hostname) || hostname.empty()) |
| 417 return v8::Null(); | 417 return v8::Null(); |
| 418 | 418 |
| 419 std::string ip_address; | 419 std::string ip_address; |
| 420 bool success; | 420 bool success; |
| 421 | 421 |
| 422 { | 422 { |
| 423 v8::Unlocker unlocker; | 423 v8::Unlocker unlocker; |
| 424 | 424 |
| 425 LogEventToCurrentRequest(context, | 425 LogEventToCurrentRequest(context, |
| 426 NetLog::PHASE_BEGIN, | 426 NetLog::PHASE_BEGIN, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 548 |
| 549 // Try parsing the PAC script. | 549 // Try parsing the PAC script. |
| 550 scoped_ptr<Context> context(new Context(js_bindings_.get())); | 550 scoped_ptr<Context> context(new Context(js_bindings_.get())); |
| 551 int rv = context->InitV8(bytes_utf8); | 551 int rv = context->InitV8(bytes_utf8); |
| 552 if (rv == OK) | 552 if (rv == OK) |
| 553 context_.reset(context.release()); | 553 context_.reset(context.release()); |
| 554 return rv; | 554 return rv; |
| 555 } | 555 } |
| 556 | 556 |
| 557 } // namespace net | 557 } // namespace net |
| OLD | NEW |