| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/debug/leak_annotations.h" | 12 #include "base/debug/leak_annotations.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/string_tokenizer.h" | 14 #include "base/strings/string_tokenizer.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "gin/array_buffer.h" |
| 18 #include "gin/public/isolate_holder.h" | 19 #include "gin/public/isolate_holder.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
| 21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 22 #include "net/proxy/proxy_info.h" | 23 #include "net/proxy/proxy_info.h" |
| 23 #include "net/proxy/proxy_resolver_script.h" | 24 #include "net/proxy/proxy_resolver_script.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 #include "url/url_canon.h" | 26 #include "url/url_canon.h" |
| 26 #include "v8/include/v8.h" | 27 #include "v8/include/v8.h" |
| 27 | 28 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 int rv = context->InitV8(script_data); | 762 int rv = context->InitV8(script_data); |
| 762 if (rv == OK) | 763 if (rv == OK) |
| 763 context_.reset(context.release()); | 764 context_.reset(context.release()); |
| 764 return rv; | 765 return rv; |
| 765 } | 766 } |
| 766 | 767 |
| 767 // static | 768 // static |
| 768 void ProxyResolverV8::EnsureIsolateCreated() { | 769 void ProxyResolverV8::EnsureIsolateCreated() { |
| 769 if (g_proxy_resolver_isolate_) | 770 if (g_proxy_resolver_isolate_) |
| 770 return; | 771 return; |
| 771 g_proxy_resolver_isolate_ = | 772 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, |
| 772 new gin::IsolateHolder(gin::IsolateHolder::kNonStrictMode); | 773 gin::ArrayBufferAllocator::SharedInstance()); |
| 774 g_proxy_resolver_isolate_ = new gin::IsolateHolder; |
| 773 ANNOTATE_LEAKING_OBJECT_PTR(g_proxy_resolver_isolate_); | 775 ANNOTATE_LEAKING_OBJECT_PTR(g_proxy_resolver_isolate_); |
| 774 } | 776 } |
| 775 | 777 |
| 776 // static | 778 // static |
| 777 v8::Isolate* ProxyResolverV8::GetDefaultIsolate() { | 779 v8::Isolate* ProxyResolverV8::GetDefaultIsolate() { |
| 778 DCHECK(g_proxy_resolver_isolate_) | 780 DCHECK(g_proxy_resolver_isolate_) |
| 779 << "Must call ProxyResolverV8::EnsureIsolateCreated() first"; | 781 << "Must call ProxyResolverV8::EnsureIsolateCreated() first"; |
| 780 return g_proxy_resolver_isolate_->isolate(); | 782 return g_proxy_resolver_isolate_->isolate(); |
| 781 } | 783 } |
| 782 | 784 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 800 return 0; | 802 return 0; |
| 801 | 803 |
| 802 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); | 804 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); |
| 803 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); | 805 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); |
| 804 v8::HeapStatistics heap_statistics; | 806 v8::HeapStatistics heap_statistics; |
| 805 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); | 807 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); |
| 806 return heap_statistics.used_heap_size(); | 808 return heap_statistics.used_heap_size(); |
| 807 } | 809 } |
| 808 | 810 |
| 809 } // namespace net | 811 } // namespace net |
| OLD | NEW |