| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/proxy/proxy_resolver.h" | 17 #include "net/proxy/proxy_resolver.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class Thread; | 20 class Thread; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 // ProxyResolverFactory is an interface for creating ProxyResolver instances. | 25 // ProxyResolverFactory is an interface for creating ProxyResolver instances. |
| 26 class ProxyResolverFactory { | 26 class ProxyResolverFactory { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // (a) Scripts whose initialization has external dependencies on network or | 65 // (a) Scripts whose initialization has external dependencies on network or |
| 66 // time may end up successfully initializing on some threads, but not | 66 // time may end up successfully initializing on some threads, but not |
| 67 // others. So depending on what thread services the request, the result | 67 // others. So depending on what thread services the request, the result |
| 68 // may jump between several possibilities. | 68 // may jump between several possibilities. |
| 69 // | 69 // |
| 70 // (b) Scripts whose FindProxyForURL() depends on side-effects may now | 70 // (b) Scripts whose FindProxyForURL() depends on side-effects may now |
| 71 // work differently. For example, a PAC script which was incrementing | 71 // work differently. For example, a PAC script which was incrementing |
| 72 // a global counter and using that to make a decision. In the | 72 // a global counter and using that to make a decision. In the |
| 73 // multi-threaded model, each thread may have a different value for this | 73 // multi-threaded model, each thread may have a different value for this |
| 74 // counter, so it won't globally be seen as monotonically increasing! | 74 // counter, so it won't globally be seen as monotonically increasing! |
| 75 class NET_TEST MultiThreadedProxyResolver | 75 class NET_EXPORT_PRIVATE MultiThreadedProxyResolver |
| 76 : public ProxyResolver, | 76 : public ProxyResolver, |
| 77 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 77 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 78 public: | 78 public: |
| 79 // Creates an asynchronous ProxyResolver that runs requests on up to | 79 // Creates an asynchronous ProxyResolver that runs requests on up to |
| 80 // |max_num_threads|. | 80 // |max_num_threads|. |
| 81 // | 81 // |
| 82 // For each thread that is created, an accompanying synchronous ProxyResolver | 82 // For each thread that is created, an accompanying synchronous ProxyResolver |
| 83 // will be provisioned using |resolver_factory|. All methods on these | 83 // will be provisioned using |resolver_factory|. All methods on these |
| 84 // ProxyResolvers will be called on the one thread, with the exception of | 84 // ProxyResolvers will be called on the one thread, with the exception of |
| 85 // ProxyResolver::Shutdown() which will be called from the origin thread | 85 // ProxyResolver::Shutdown() which will be called from the origin thread |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 const scoped_ptr<ProxyResolverFactory> resolver_factory_; | 134 const scoped_ptr<ProxyResolverFactory> resolver_factory_; |
| 135 const size_t max_num_threads_; | 135 const size_t max_num_threads_; |
| 136 PendingJobsQueue pending_jobs_; | 136 PendingJobsQueue pending_jobs_; |
| 137 ExecutorList executors_; | 137 ExecutorList executors_; |
| 138 scoped_refptr<ProxyResolverScriptData> current_script_data_; | 138 scoped_refptr<ProxyResolverScriptData> current_script_data_; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace net | 141 } // namespace net |
| 142 | 142 |
| 143 #endif // NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ | 143 #endif // NET_PROXY_MULTI_THREADED_PROXY_RESOLVER_H_ |
| OLD | NEW |