Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: net/proxy/proxy_resolver_v8.h

Issue 11959029: Make the v8 Isolate used in the proxy resolver explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed component build Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 v8 {
14 class Isolate;
15 } // namespace v8
16
13 namespace net { 17 namespace net {
14 18
15 class ProxyResolverJSBindings; 19 class ProxyResolverJSBindings;
16 20
17 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. 21 // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts.
18 // 22 //
19 // ---------------------------------------------------------------------------- 23 // ----------------------------------------------------------------------------
20 // !!! Important note on threading model: 24 // !!! Important note on threading model:
eroman 2013/01/18 19:21:14 Please update this comment.
Sven Panne 2013/01/21 08:50:06 This comment is still OK. The v8_default_isolate b
21 // ---------------------------------------------------------------------------- 25 // ----------------------------------------------------------------------------
22 // There can be only one instance of V8 running at a time. To enforce this 26 // There can be only one instance of V8 running at a time. To enforce this
23 // constraint, ProxyResolverV8 holds a v8::Locker during execution. Therefore 27 // constraint, ProxyResolverV8 holds a v8::Locker during execution. Therefore
24 // it is OK to run multiple instances of ProxyResolverV8 on different threads, 28 // it is OK to run multiple instances of ProxyResolverV8 on different threads,
25 // since only one will be running inside V8 at a time. 29 // since only one will be running inside V8 at a time.
26 // 30 //
27 // It is important that *ALL* instances of V8 in the process be using 31 // It is important that *ALL* instances of V8 in the process be using
28 // v8::Locker. If not there can be race conditions between the non-locked V8 32 // v8::Locker. If not there can be race conditions between the non-locked V8
29 // instances and the locked V8 instances used by ProxyResolverV8 (assuming they 33 // instances and the locked V8 instances used by ProxyResolverV8 (assuming they
30 // run on different threads). 34 // run on different threads).
31 // 35 //
32 // This is the case with the V8 instance used by chromium's renderer -- it runs 36 // This is the case with the V8 instance used by chromium's renderer -- it runs
33 // on a different thread from ProxyResolver (renderer thread vs PAC thread), 37 // on a different thread from ProxyResolver (renderer thread vs PAC thread),
34 // and does not use locking since it expects to be alone. 38 // and does not use locking since it expects to be alone.
35 class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver { 39 class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver {
36 public: 40 public:
37 // Constructs a ProxyResolverV8 with custom bindings. ProxyResolverV8 takes 41 // Constructs a ProxyResolverV8 with custom bindings. ProxyResolverV8 takes
38 // ownership of |custom_js_bindings| and deletes it when ProxyResolverV8 42 // ownership of |custom_js_bindings| and deletes it when ProxyResolverV8
39 // is destroyed. 43 // is destroyed.
40 explicit ProxyResolverV8(ProxyResolverJSBindings* custom_js_bindings); 44 ProxyResolverV8(ProxyResolverJSBindings* custom_js_bindings,
45 v8::Isolate* v8_default_isolate);
41 46
42 virtual ~ProxyResolverV8(); 47 virtual ~ProxyResolverV8();
43 48
44 ProxyResolverJSBindings* js_bindings() const { return js_bindings_.get(); } 49 ProxyResolverJSBindings* js_bindings() const { return js_bindings_.get(); }
45 50
46 // ProxyResolver implementation: 51 // ProxyResolver implementation:
47 virtual int GetProxyForURL(const GURL& url, 52 virtual int GetProxyForURL(const GURL& url,
48 ProxyInfo* results, 53 ProxyInfo* results,
49 const net::CompletionCallback& /*callback*/, 54 const net::CompletionCallback& /*callback*/,
50 RequestHandle* /*request*/, 55 RequestHandle* /*request*/,
(...skipping 11 matching lines...) Expand all
62 67
63 private: 68 private:
64 // Context holds the Javascript state for the most recently loaded PAC 69 // Context holds the Javascript state for the most recently loaded PAC
65 // script. It corresponds with the data from the last call to 70 // script. It corresponds with the data from the last call to
66 // SetPacScript(). 71 // SetPacScript().
67 class Context; 72 class Context;
68 scoped_ptr<Context> context_; 73 scoped_ptr<Context> context_;
69 74
70 scoped_ptr<ProxyResolverJSBindings> js_bindings_; 75 scoped_ptr<ProxyResolverJSBindings> js_bindings_;
71 76
77 v8::Isolate* v8_default_isolate_;
78
72 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); 79 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8);
73 }; 80 };
74 81
75 } // namespace net 82 } // namespace net
76 83
77 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ 84 #endif // NET_PROXY_PROXY_RESOLVER_V8_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698