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_MULTI_THREADED_PROXY_RESOLVER_H_ | 5 #ifndef NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ |
6 #define NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ | 6 #define NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 // (a) Scripts whose initialization has external dependencies on network or | 64 // (a) Scripts whose initialization has external dependencies on network or |
65 // time may end up successfully initializing on some threads, but not | 65 // time may end up successfully initializing on some threads, but not |
66 // others. So depending on what thread services the request, the result | 66 // others. So depending on what thread services the request, the result |
67 // may jump between several possibilities. | 67 // may jump between several possibilities. |
68 // | 68 // |
69 // (b) Scripts whose FindProxyForURL() depends on side-effects may now | 69 // (b) Scripts whose FindProxyForURL() depends on side-effects may now |
70 // work differently. For example, a PAC script which was incrementing | 70 // work differently. For example, a PAC script which was incrementing |
71 // a global counter and using that to make a decision. In the | 71 // a global counter and using that to make a decision. In the |
72 // multi-threaded model, each thread may have a different value for this | 72 // multi-threaded model, each thread may have a different value for this |
73 // counter, so it won't globally be seen as monotonically increasing! | 73 // counter, so it won't globally be seen as monotonically increasing! |
74 class NET_EXPORT_PRIVATE MultiThreadedProxyResolver | 74 class NET_EXPORT_PRIVATE MultiThreadedProxyResolver |
mmenke
2013/01/18 19:59:40
Not getting rid of this?
eroman
2013/01/23 03:26:02
I would love to get rid of that, unfortunately the
| |
75 : public ProxyResolver, | 75 : public ProxyResolver, |
76 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 76 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
77 public: | 77 public: |
78 // Creates an asynchronous ProxyResolver that runs requests on up to | 78 // Creates an asynchronous ProxyResolver that runs requests on up to |
79 // |max_num_threads|. | 79 // |max_num_threads|. |
80 // | 80 // |
81 // For each thread that is created, an accompanying synchronous ProxyResolver | 81 // For each thread that is created, an accompanying synchronous ProxyResolver |
82 // will be provisioned using |resolver_factory|. All methods on these | 82 // will be provisioned using |resolver_factory|. All methods on these |
83 // ProxyResolvers will be called on the one thread, with the exception of | 83 // ProxyResolvers will be called on the one thread, with the exception of |
84 // ProxyResolver::Shutdown() which will be called from the origin thread | 84 // ProxyResolver::Shutdown() which will be called from the origin thread |
85 // prior to destruction. | 85 // prior to destruction. |
86 // | 86 // |
87 // The constructor takes ownership of |resolver_factory|. | 87 // The constructor takes ownership of |resolver_factory|. |
88 MultiThreadedProxyResolver(ProxyResolverFactory* resolver_factory, | 88 MultiThreadedProxyResolver(ProxyResolverFactory* resolver_factory, |
89 size_t max_num_threads); | 89 size_t max_num_threads); |
90 | 90 |
91 virtual ~MultiThreadedProxyResolver(); | 91 virtual ~MultiThreadedProxyResolver(); |
92 | 92 |
93 // ProxyResolver implementation: | 93 // ProxyResolver implementation: |
94 virtual int GetProxyForURL(const GURL& url, | 94 virtual int GetProxyForURL(const GURL& url, |
95 ProxyInfo* results, | 95 ProxyInfo* results, |
96 const CompletionCallback& callback, | 96 const CompletionCallback& callback, |
97 RequestHandle* request, | 97 RequestHandle* request, |
98 const BoundNetLog& net_log) OVERRIDE; | 98 const BoundNetLog& net_log) OVERRIDE; |
99 virtual void CancelRequest(RequestHandle request) OVERRIDE; | 99 virtual void CancelRequest(RequestHandle request) OVERRIDE; |
100 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE; | 100 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE; |
101 virtual LoadState GetLoadStateThreadSafe( | |
102 RequestHandle request) const OVERRIDE; | |
103 virtual void CancelSetPacScript() OVERRIDE; | 101 virtual void CancelSetPacScript() OVERRIDE; |
104 virtual void PurgeMemory() OVERRIDE; | 102 virtual void PurgeMemory() OVERRIDE; |
105 virtual int SetPacScript( | 103 virtual int SetPacScript( |
106 const scoped_refptr<ProxyResolverScriptData>& script_data, | 104 const scoped_refptr<ProxyResolverScriptData>& script_data, |
107 const CompletionCallback& callback) OVERRIDE; | 105 const CompletionCallback& callback) OVERRIDE; |
108 | 106 |
109 private: | 107 private: |
110 class Executor; | 108 class Executor; |
111 class Job; | 109 class Job; |
112 class SetPacScriptJob; | 110 class SetPacScriptJob; |
(...skipping 23 matching lines...) Expand all Loading... | |
136 const scoped_ptr<ProxyResolverFactory> resolver_factory_; | 134 const scoped_ptr<ProxyResolverFactory> resolver_factory_; |
137 const size_t max_num_threads_; | 135 const size_t max_num_threads_; |
138 PendingJobsQueue pending_jobs_; | 136 PendingJobsQueue pending_jobs_; |
139 ExecutorList executors_; | 137 ExecutorList executors_; |
140 scoped_refptr<ProxyResolverScriptData> current_script_data_; | 138 scoped_refptr<ProxyResolverScriptData> current_script_data_; |
141 }; | 139 }; |
142 | 140 |
143 } // namespace net | 141 } // namespace net |
144 | 142 |
145 #endif // NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ | 143 #endif // NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ |
OLD | NEW |