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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 const base::string16 hostname_utf16 = V8StringToUTF16(args[0]->ToString()); | 218 const base::string16 hostname_utf16 = V8StringToUTF16(args[0]->ToString()); |
219 | 219 |
220 // If the hostname is already in ASCII, simply return it as is. | 220 // If the hostname is already in ASCII, simply return it as is. |
221 if (IsStringASCII(hostname_utf16)) { | 221 if (IsStringASCII(hostname_utf16)) { |
222 *hostname = base::UTF16ToASCII(hostname_utf16); | 222 *hostname = base::UTF16ToASCII(hostname_utf16); |
223 return true; | 223 return true; |
224 } | 224 } |
225 | 225 |
226 // Otherwise try to convert it from IDN to punycode. | 226 // Otherwise try to convert it from IDN to punycode. |
227 const int kInitialBufferSize = 256; | 227 const int kInitialBufferSize = 256; |
228 url_canon::RawCanonOutputT<base::char16, kInitialBufferSize> punycode_output; | 228 url::RawCanonOutputT<base::char16, kInitialBufferSize> punycode_output; |
229 if (!url_canon::IDNToASCII(hostname_utf16.data(), | 229 if (!url::IDNToASCII(hostname_utf16.data(), hostname_utf16.length(), |
230 hostname_utf16.length(), | 230 &punycode_output)) { |
231 &punycode_output)) { | |
232 return false; | 231 return false; |
233 } | 232 } |
234 | 233 |
235 // |punycode_output| should now be ASCII; convert it to a std::string. | 234 // |punycode_output| should now be ASCII; convert it to a std::string. |
236 // (We could use UTF16ToASCII() instead, but that requires an extra string | 235 // (We could use UTF16ToASCII() instead, but that requires an extra string |
237 // copy. Since ASCII is a subset of UTF8 the following is equivalent). | 236 // copy. Since ASCII is a subset of UTF8 the following is equivalent). |
238 bool success = base::UTF16ToUTF8(punycode_output.data(), | 237 bool success = base::UTF16ToUTF8(punycode_output.data(), |
239 punycode_output.length(), | 238 punycode_output.length(), |
240 hostname); | 239 hostname); |
241 DCHECK(success); | 240 DCHECK(success); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 return 0; | 800 return 0; |
802 | 801 |
803 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); | 802 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); |
804 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); | 803 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); |
805 v8::HeapStatistics heap_statistics; | 804 v8::HeapStatistics heap_statistics; |
806 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); | 805 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); |
807 return heap_statistics.used_heap_size(); | 806 return heap_statistics.used_heap_size(); |
808 } | 807 } |
809 | 808 |
810 } // namespace net | 809 } // namespace net |
OLD | NEW |