| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Allows interceptors to hijack the request after examining the response | 44 // Allows interceptors to hijack the request after examining the response |
| 45 // status and headers. This is also called when there is no server response | 45 // status and headers. This is also called when there is no server response |
| 46 // at all to allow interception of failed requests due to network errors. | 46 // at all to allow interception of failed requests due to network errors. |
| 47 // Returns NULL if no interceptor intervenes. | 47 // Returns NULL if no interceptor intervenes. |
| 48 URLRequestJob* MaybeInterceptResponse( | 48 URLRequestJob* MaybeInterceptResponse( |
| 49 URLRequest* request, NetworkDelegate* network_delegate) const; | 49 URLRequest* request, NetworkDelegate* network_delegate) const; |
| 50 | 50 |
| 51 // Returns true if the manager has a built-in handler for |scheme|. | 51 // Returns true if the manager has a built-in handler for |scheme|. |
| 52 static bool SupportsScheme(const std::string& scheme); | 52 static bool SupportsScheme(const std::string& scheme); |
| 53 | 53 |
| 54 // Register/unregister a request interceptor. | |
| 55 void RegisterRequestInterceptor(URLRequest::Interceptor* interceptor); | |
| 56 void UnregisterRequestInterceptor(URLRequest::Interceptor* interceptor); | |
| 57 | |
| 58 private: | 54 private: |
| 59 typedef std::vector<URLRequest::Interceptor*> InterceptorList; | |
| 60 friend struct DefaultSingletonTraits<URLRequestJobManager>; | 55 friend struct DefaultSingletonTraits<URLRequestJobManager>; |
| 61 | 56 |
| 62 URLRequestJobManager(); | 57 URLRequestJobManager(); |
| 63 ~URLRequestJobManager(); | 58 ~URLRequestJobManager(); |
| 64 | 59 |
| 65 // The first guy to call this function sets the allowed thread. This way we | 60 // The first guy to call this function sets the allowed thread. This way we |
| 66 // avoid needing to define that thread externally. Since we expect all | 61 // avoid needing to define that thread externally. Since we expect all |
| 67 // callers to be on the same thread, we don't worry about threads racing to | 62 // callers to be on the same thread, we don't worry about threads racing to |
| 68 // set the allowed thread. | 63 // set the allowed thread. |
| 69 bool IsAllowedThread() const { | 64 bool IsAllowedThread() const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 85 return true; | 80 return true; |
| 86 } | 81 } |
| 87 | 82 |
| 88 // We use this to assert that CreateJob and the registration functions all | 83 // We use this to assert that CreateJob and the registration functions all |
| 89 // run on the same thread. | 84 // run on the same thread. |
| 90 mutable base::PlatformThreadId allowed_thread_; | 85 mutable base::PlatformThreadId allowed_thread_; |
| 91 mutable bool allowed_thread_initialized_; | 86 mutable bool allowed_thread_initialized_; |
| 92 #endif | 87 #endif |
| 93 | 88 |
| 94 mutable base::Lock lock_; | 89 mutable base::Lock lock_; |
| 95 InterceptorList interceptors_; | |
| 96 | 90 |
| 97 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); | 91 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); |
| 98 }; | 92 }; |
| 99 | 93 |
| 100 } // namespace net | 94 } // namespace net |
| 101 | 95 |
| 102 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ | 96 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H_ |
| OLD | NEW |