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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/base/net_api.h" | 11 #include "net/base/net_export.h" |
12 #include "net/proxy/proxy_resolver.h" | 12 #include "net/proxy/proxy_resolver.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 class ProxyResolverJSBindings; | 16 class ProxyResolverJSBindings; |
17 | 17 |
18 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. | 18 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. |
19 // | 19 // |
20 // ---------------------------------------------------------------------------- | 20 // ---------------------------------------------------------------------------- |
21 // !!! Important note on threading model: | 21 // !!! Important note on threading model: |
22 // ---------------------------------------------------------------------------- | 22 // ---------------------------------------------------------------------------- |
23 // There can be only one instance of V8 running at a time. To enforce this | 23 // There can be only one instance of V8 running at a time. To enforce this |
24 // constraint, ProxyResolverV8 holds a v8::Locker during execution. Therefore | 24 // constraint, ProxyResolverV8 holds a v8::Locker during execution. Therefore |
25 // it is OK to run multiple instances of ProxyResolverV8 on different threads, | 25 // it is OK to run multiple instances of ProxyResolverV8 on different threads, |
26 // since only one will be running inside V8 at a time. | 26 // since only one will be running inside V8 at a time. |
27 // | 27 // |
28 // It is important that *ALL* instances of V8 in the process be using | 28 // It is important that *ALL* instances of V8 in the process be using |
29 // v8::Locker. If not there can be race conditions beween the non-locked V8 | 29 // v8::Locker. If not there can be race conditions beween the non-locked V8 |
30 // instances and the locked V8 instances used by ProxyResolverV8 (assuming they | 30 // instances and the locked V8 instances used by ProxyResolverV8 (assuming they |
31 // run on different threads). | 31 // run on different threads). |
32 // | 32 // |
33 // This is the case with the V8 instance used by chromium's renderer -- it runs | 33 // This is the case with the V8 instance used by chromium's renderer -- it runs |
34 // on a different thread from ProxyResolver (renderer thread vs PAC thread), | 34 // on a different thread from ProxyResolver (renderer thread vs PAC thread), |
35 // and does not use locking since it expects to be alone. | 35 // and does not use locking since it expects to be alone. |
36 class NET_TEST ProxyResolverV8 : public ProxyResolver { | 36 class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver { |
37 public: | 37 public: |
38 // Constructs a ProxyResolverV8 with custom bindings. ProxyResolverV8 takes | 38 // Constructs a ProxyResolverV8 with custom bindings. ProxyResolverV8 takes |
39 // ownership of |custom_js_bindings| and deletes it when ProxyResolverV8 | 39 // ownership of |custom_js_bindings| and deletes it when ProxyResolverV8 |
40 // is destroyed. | 40 // is destroyed. |
41 explicit ProxyResolverV8(ProxyResolverJSBindings* custom_js_bindings); | 41 explicit ProxyResolverV8(ProxyResolverJSBindings* custom_js_bindings); |
42 | 42 |
43 virtual ~ProxyResolverV8(); | 43 virtual ~ProxyResolverV8(); |
44 | 44 |
45 ProxyResolverJSBindings* js_bindings() const { return js_bindings_.get(); } | 45 ProxyResolverJSBindings* js_bindings() const { return js_bindings_.get(); } |
46 | 46 |
(...skipping 19 matching lines...) Expand all Loading... |
66 scoped_ptr<Context> context_; | 66 scoped_ptr<Context> context_; |
67 | 67 |
68 scoped_ptr<ProxyResolverJSBindings> js_bindings_; | 68 scoped_ptr<ProxyResolverJSBindings> js_bindings_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); | 70 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace net | 73 } // namespace net |
74 | 74 |
75 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ | 75 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ |
OLD | NEW |