| OLD | NEW |
| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 const base::string16 hostname_utf16 = V8StringToUTF16(args[0]->ToString()); | 216 const base::string16 hostname_utf16 = V8StringToUTF16(args[0]->ToString()); |
| 217 | 217 |
| 218 // If the hostname is already in ASCII, simply return it as is. | 218 // If the hostname is already in ASCII, simply return it as is. |
| 219 if (IsStringASCII(hostname_utf16)) { | 219 if (IsStringASCII(hostname_utf16)) { |
| 220 *hostname = UTF16ToASCII(hostname_utf16); | 220 *hostname = UTF16ToASCII(hostname_utf16); |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Otherwise try to convert it from IDN to punycode. | 224 // Otherwise try to convert it from IDN to punycode. |
| 225 const int kInitialBufferSize = 256; | 225 const int kInitialBufferSize = 256; |
| 226 url_canon::RawCanonOutputT<char16, kInitialBufferSize> punycode_output; | 226 url_canon::RawCanonOutputT<base::char16, kInitialBufferSize> punycode_output; |
| 227 if (!url_canon::IDNToASCII(hostname_utf16.data(), | 227 if (!url_canon::IDNToASCII(hostname_utf16.data(), |
| 228 hostname_utf16.length(), | 228 hostname_utf16.length(), |
| 229 &punycode_output)) { | 229 &punycode_output)) { |
| 230 return false; | 230 return false; |
| 231 } | 231 } |
| 232 | 232 |
| 233 // |punycode_output| should now be ASCII; convert it to a std::string. | 233 // |punycode_output| should now be ASCII; convert it to a std::string. |
| 234 // (We could use UTF16ToASCII() instead, but that requires an extra string | 234 // (We could use UTF16ToASCII() instead, but that requires an extra string |
| 235 // copy. Since ASCII is a subset of UTF8 the following is equivalent). | 235 // copy. Since ASCII is a subset of UTF8 the following is equivalent). |
| 236 bool success = base::UTF16ToUTF8(punycode_output.data(), | 236 bool success = base::UTF16ToUTF8(punycode_output.data(), |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 return 0; | 824 return 0; |
| 825 | 825 |
| 826 v8::Locker locked(g_default_isolate_); | 826 v8::Locker locked(g_default_isolate_); |
| 827 v8::Isolate::Scope isolate_scope(g_default_isolate_); | 827 v8::Isolate::Scope isolate_scope(g_default_isolate_); |
| 828 v8::HeapStatistics heap_statistics; | 828 v8::HeapStatistics heap_statistics; |
| 829 g_default_isolate_->GetHeapStatistics(&heap_statistics); | 829 g_default_isolate_->GetHeapStatistics(&heap_statistics); |
| 830 return heap_statistics.used_heap_size(); | 830 return heap_statistics.used_heap_size(); |
| 831 } | 831 } |
| 832 | 832 |
| 833 } // namespace net | 833 } // namespace net |
| OLD | NEW |