| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool enable_file_access() const { return enable_file_access_; } | 69 bool enable_file_access() const { return enable_file_access_; } |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 typedef std::map<std::string, net::URLRequest::ProtocolFactory*> FactoryMap; | 72 typedef std::map<std::string, net::URLRequest::ProtocolFactory*> FactoryMap; |
| 73 typedef std::vector<net::URLRequest::Interceptor*> InterceptorList; | 73 typedef std::vector<net::URLRequest::Interceptor*> InterceptorList; |
| 74 friend struct DefaultSingletonTraits<URLRequestJobManager>; | 74 friend struct DefaultSingletonTraits<URLRequestJobManager>; |
| 75 | 75 |
| 76 URLRequestJobManager(); | 76 URLRequestJobManager(); |
| 77 ~URLRequestJobManager(); | 77 ~URLRequestJobManager(); |
| 78 | 78 |
| 79 mutable base::Lock lock_; | |
| 80 FactoryMap factories_; | |
| 81 InterceptorList interceptors_; | |
| 82 bool enable_file_access_; | |
| 83 | |
| 84 #ifndef NDEBUG | 79 #ifndef NDEBUG |
| 85 // We use this to assert that CreateJob and the registration functions all | |
| 86 // run on the same thread. | |
| 87 mutable base::PlatformThreadId allowed_thread_; | |
| 88 mutable bool allowed_thread_initialized_; | |
| 89 | |
| 90 // The first guy to call this function sets the allowed thread. This way we | 80 // The first guy to call this function sets the allowed thread. This way we |
| 91 // avoid needing to define that thread externally. Since we expect all | 81 // avoid needing to define that thread externally. Since we expect all |
| 92 // callers to be on the same thread, we don't worry about threads racing to | 82 // callers to be on the same thread, we don't worry about threads racing to |
| 93 // set the allowed thread. | 83 // set the allowed thread. |
| 94 bool IsAllowedThread() const { | 84 bool IsAllowedThread() const { |
| 95 #if 0 | 85 #if 0 |
| 96 if (!allowed_thread_initialized_) { | 86 if (!allowed_thread_initialized_) { |
| 97 allowed_thread_ = base::PlatformThread::CurrentId(); | 87 allowed_thread_ = base::PlatformThread::CurrentId(); |
| 98 allowed_thread_initialized_ = true; | 88 allowed_thread_initialized_ = true; |
| 99 } | 89 } |
| 100 return allowed_thread_ == base::PlatformThread::CurrentId(); | 90 return allowed_thread_ == base::PlatformThread::CurrentId(); |
| 101 #else | 91 #else |
| 102 // The previous version of this check used GetCurrentThread on Windows to | 92 // The previous version of this check used GetCurrentThread on Windows to |
| 103 // get thread handles to compare. Unfortunately, GetCurrentThread returns | 93 // get thread handles to compare. Unfortunately, GetCurrentThread returns |
| 104 // a constant psuedo-handle (0xFFFFFFFE), and therefore IsAllowedThread | 94 // a constant psuedo-handle (0xFFFFFFFE), and therefore IsAllowedThread |
| 105 // always returned true. The above code that's turned off is the correct | 95 // always returned true. The above code that's turned off is the correct |
| 106 // code, but causes the tree to turn red because some caller isn't | 96 // code, but causes the tree to turn red because some caller isn't |
| 107 // respecting our thread requirements. We're turning off the check for now; | 97 // respecting our thread requirements. We're turning off the check for now; |
| 108 // bug http://b/issue?id=1338969 has been filed to fix things and turn the | 98 // bug http://b/issue?id=1338969 has been filed to fix things and turn the |
| 109 // check back on. | 99 // check back on. |
| 110 return true; | 100 return true; |
| 111 #endif | 101 #endif |
| 112 } | 102 } |
| 103 |
| 104 // We use this to assert that CreateJob and the registration functions all |
| 105 // run on the same thread. |
| 106 mutable base::PlatformThreadId allowed_thread_; |
| 107 mutable bool allowed_thread_initialized_; |
| 113 #endif | 108 #endif |
| 114 | 109 |
| 110 mutable base::Lock lock_; |
| 111 FactoryMap factories_; |
| 112 InterceptorList interceptors_; |
| 113 bool enable_file_access_; |
| 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); | 115 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace net | 118 } // namespace net |
| 119 | 119 |
| 120 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ | 120 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ |
| OLD | NEW |