OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_PROXY_PROXY_RESOLVER_V8_H_ | 5 #ifndef NET_PROXY_PROXY_RESOLVER_V8_H_ |
6 #define NET_PROXY_PROXY_RESOLVER_V8_H_ | 6 #define NET_PROXY_PROXY_RESOLVER_V8_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
11 #include "net/proxy/proxy_resolver.h" | 11 #include "net/proxy/proxy_resolver.h" |
12 | 12 |
| 13 namespace gin { |
| 14 class IsolateHolder; |
| 15 } // namespace gin |
| 16 |
13 namespace v8 { | 17 namespace v8 { |
14 class HeapStatistics; | 18 class HeapStatistics; |
15 class Isolate; | 19 class Isolate; |
16 } // namespace v8 | 20 } // namespace v8 |
17 | 21 |
18 namespace net { | 22 namespace net { |
19 | 23 |
20 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. | 24 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. |
21 // | 25 // |
22 // ---------------------------------------------------------------------------- | 26 // ---------------------------------------------------------------------------- |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const net::CompletionCallback& /*callback*/, | 87 const net::CompletionCallback& /*callback*/, |
84 RequestHandle* /*request*/, | 88 RequestHandle* /*request*/, |
85 const BoundNetLog& net_log) OVERRIDE; | 89 const BoundNetLog& net_log) OVERRIDE; |
86 virtual void CancelRequest(RequestHandle request) OVERRIDE; | 90 virtual void CancelRequest(RequestHandle request) OVERRIDE; |
87 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE; | 91 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE; |
88 virtual void CancelSetPacScript() OVERRIDE; | 92 virtual void CancelSetPacScript() OVERRIDE; |
89 virtual int SetPacScript( | 93 virtual int SetPacScript( |
90 const scoped_refptr<ProxyResolverScriptData>& script_data, | 94 const scoped_refptr<ProxyResolverScriptData>& script_data, |
91 const net::CompletionCallback& /*callback*/) OVERRIDE; | 95 const net::CompletionCallback& /*callback*/) OVERRIDE; |
92 | 96 |
93 // Remember the default Isolate, must be called from the main thread. This | 97 // Create an isolate to use for the proxy resolver. If the embedder invokes |
94 // hack can be removed when the "default Isolate" concept is gone. | 98 // this method multiple times, it must be invoked in a thread safe manner, |
95 static void RememberDefaultIsolate(); | 99 // e.g. always from the same thread. |
96 | 100 static void EnsureIsolateCreated(); |
97 #if defined(OS_WIN) | |
98 // Create an isolate to use for the proxy resolver. Until the "default | |
99 // Isolate" concept is gone, it is preferable to invoke | |
100 // RememberDefaultIsolate() as creating a new Isolate in additional to the | |
101 // default Isolate will waste a few MB of memory and the runtime it took to | |
102 // create the default Isolate. | |
103 static void CreateIsolate(); | |
104 #endif | |
105 | 101 |
106 static v8::Isolate* GetDefaultIsolate(); | 102 static v8::Isolate* GetDefaultIsolate(); |
107 | 103 |
108 // Get total/ued heap memory usage of all v8 instances used by the proxy | 104 // Get total/ued heap memory usage of all v8 instances used by the proxy |
109 // resolver. | 105 // resolver. |
110 static size_t GetTotalHeapSize(); | 106 static size_t GetTotalHeapSize(); |
111 static size_t GetUsedHeapSize(); | 107 static size_t GetUsedHeapSize(); |
112 | 108 |
113 private: | 109 private: |
114 static v8::Isolate* g_default_isolate_; | 110 static gin::IsolateHolder* g_proxy_resolver_isolate_; |
115 | 111 |
116 // Context holds the Javascript state for the most recently loaded PAC | 112 // Context holds the Javascript state for the most recently loaded PAC |
117 // script. It corresponds with the data from the last call to | 113 // script. It corresponds with the data from the last call to |
118 // SetPacScript(). | 114 // SetPacScript(). |
119 class Context; | 115 class Context; |
120 | 116 |
121 scoped_ptr<Context> context_; | 117 scoped_ptr<Context> context_; |
122 | 118 |
123 JSBindings* js_bindings_; | 119 JSBindings* js_bindings_; |
124 | 120 |
125 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); | 121 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); |
126 }; | 122 }; |
127 | 123 |
128 } // namespace net | 124 } // namespace net |
129 | 125 |
130 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ | 126 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ |
OLD | NEW |