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/array_buffer.h" |
19 #include "gin/public/isolate_holder.h" | 19 #include "gin/public/isolate_holder.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
23 #include "net/proxy/proxy_info.h" | 23 #include "net/proxy/proxy_info.h" |
24 #include "net/proxy/proxy_resolver_script.h" | 24 #include "net/proxy/proxy_resolver_script.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 #include "url/url_canon.h" | 26 #include "url/url_canon.h" |
27 #include "v8/include/v8.h" | 27 #include "v8/include/v8.h" |
28 | 28 |
29 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
30 #include "gin/public/isolate_holder.h" | |
31 #endif | |
32 | |
29 // Notes on the javascript environment: | 33 // Notes on the javascript environment: |
30 // | 34 // |
31 // For the majority of the PAC utility functions, we use the same code | 35 // For the majority of the PAC utility functions, we use the same code |
32 // as Firefox. See the javascript library that proxy_resolver_scipt.h | 36 // as Firefox. See the javascript library that proxy_resolver_scipt.h |
33 // pulls in. | 37 // pulls in. |
34 // | 38 // |
35 // In addition, we implement a subset of Microsoft's extensions to PAC. | 39 // In addition, we implement a subset of Microsoft's extensions to PAC. |
36 // - myIpAddressEx() | 40 // - myIpAddressEx() |
37 // - dnsResolveEx() | 41 // - dnsResolveEx() |
38 // - isResolvableEx() | 42 // - isResolvableEx() |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 int rv = context->InitV8(script_data); | 766 int rv = context->InitV8(script_data); |
763 if (rv == OK) | 767 if (rv == OK) |
764 context_.reset(context.release()); | 768 context_.reset(context.release()); |
765 return rv; | 769 return rv; |
766 } | 770 } |
767 | 771 |
768 // static | 772 // static |
769 void ProxyResolverV8::EnsureIsolateCreated() { | 773 void ProxyResolverV8::EnsureIsolateCreated() { |
770 if (g_proxy_resolver_isolate_) | 774 if (g_proxy_resolver_isolate_) |
771 return; | 775 return; |
776 | |
777 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
778 gin::IsolateHolder::LoadV8Snapshot(); | |
779 #endif | |
780 | |
rmcilroy
2014/10/07 16:16:11
nit - remove newline
baixo
2014/10/08 11:28:55
Done.
| |
772 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, | 781 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, |
773 gin::ArrayBufferAllocator::SharedInstance()); | 782 gin::ArrayBufferAllocator::SharedInstance()); |
774 g_proxy_resolver_isolate_ = new gin::IsolateHolder; | 783 g_proxy_resolver_isolate_ = new gin::IsolateHolder; |
775 ANNOTATE_LEAKING_OBJECT_PTR(g_proxy_resolver_isolate_); | 784 ANNOTATE_LEAKING_OBJECT_PTR(g_proxy_resolver_isolate_); |
776 } | 785 } |
777 | 786 |
778 // static | 787 // static |
779 v8::Isolate* ProxyResolverV8::GetDefaultIsolate() { | 788 v8::Isolate* ProxyResolverV8::GetDefaultIsolate() { |
780 DCHECK(g_proxy_resolver_isolate_) | 789 DCHECK(g_proxy_resolver_isolate_) |
781 << "Must call ProxyResolverV8::EnsureIsolateCreated() first"; | 790 << "Must call ProxyResolverV8::EnsureIsolateCreated() first"; |
(...skipping 20 matching lines...) Expand all Loading... | |
802 return 0; | 811 return 0; |
803 | 812 |
804 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); | 813 v8::Locker locked(g_proxy_resolver_isolate_->isolate()); |
805 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); | 814 v8::Isolate::Scope isolate_scope(g_proxy_resolver_isolate_->isolate()); |
806 v8::HeapStatistics heap_statistics; | 815 v8::HeapStatistics heap_statistics; |
807 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); | 816 g_proxy_resolver_isolate_->isolate()->GetHeapStatistics(&heap_statistics); |
808 return heap_statistics.used_heap_size(); | 817 return heap_statistics.used_heap_size(); |
809 } | 818 } |
810 | 819 |
811 } // namespace net | 820 } // namespace net |
OLD | NEW |