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