| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <map> | 8 #include <map> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/lock.h" | 11 #include "base/lock.h" |
| 11 #include "base/platform_thread.h" | 12 #include "base/platform_thread.h" |
| 12 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
| 13 | 14 |
| 14 // This class is responsible for managing the set of protocol factories and | 15 // This class is responsible for managing the set of protocol factories and |
| 15 // request interceptors that determine how an URLRequestJob gets created to | 16 // request interceptors that determine how an URLRequestJob gets created to |
| 16 // handle an URLRequest. | 17 // handle an URLRequest. |
| 17 // | 18 // |
| 18 // MULTI-THREADING NOTICE: | 19 // MULTI-THREADING NOTICE: |
| 19 // URLRequest is designed to have all consumers on a single thread, and so no | 20 // URLRequest is designed to have all consumers on a single thread, and so no |
| 20 // attempt is made to support ProtocolFactory or Interceptor instances being | 21 // attempt is made to support ProtocolFactory or Interceptor instances being |
| 21 // registered/unregistered or in any way poked on multiple threads. However, | 22 // registered/unregistered or in any way poked on multiple threads. However, |
| 22 // we do support checking for supported schemes FROM ANY THREAD (i.e., it is | 23 // we do support checking for supported schemes FROM ANY THREAD (i.e., it is |
| 23 // safe to call SupportsScheme on any thread). | 24 // safe to call SupportsScheme on any thread). |
| 24 // | 25 // |
| 25 class URLRequestJobManager { | 26 class URLRequestJobManager { |
| 26 public: | 27 public: |
| 27 URLRequestJobManager(); | 28 URLRequestJobManager(); |
| 28 | 29 |
| 29 // Instantiate an URLRequestJob implementation based on the registered | 30 // Instantiate an URLRequestJob implementation based on the registered |
| 30 // interceptors and protocol factories. This will always succeed in | 31 // interceptors and protocol factories. This will always succeed in |
| 31 // returning a job unless we are--in the extreme case--out of memory. | 32 // returning a job unless we are--in the extreme case--out of memory. |
| 32 URLRequestJob* CreateJob(URLRequest* request) const; | 33 URLRequestJob* CreateJob(URLRequest* request) const; |
| 33 | 34 |
| 35 // Allows interceptors to hijack the request after examining the new location |
| 36 // of a redirect. Returns NULL if no interceptor intervenes. |
| 37 URLRequestJob* MaybeInterceptRedirect(URLRequest* request, |
| 38 const GURL& location) const; |
| 39 |
| 40 // Allows interceptors to hijack the request after examining the response |
| 41 // status and headers. This is also called when there is no server response |
| 42 // at all to allow interception of failed requests due to network errors. |
| 43 // Returns NULL if no interceptor intervenes. |
| 44 URLRequestJob* MaybeInterceptResponse(URLRequest* request) const; |
| 45 |
| 34 // Returns true if there is a protocol factory registered for the given | 46 // Returns true if there is a protocol factory registered for the given |
| 35 // scheme. Note: also returns true if there is a built-in handler for the | 47 // scheme. Note: also returns true if there is a built-in handler for the |
| 36 // given scheme. | 48 // given scheme. |
| 37 bool SupportsScheme(const std::string& scheme) const; | 49 bool SupportsScheme(const std::string& scheme) const; |
| 38 | 50 |
| 39 // Register a protocol factory associated with the given scheme. The factory | 51 // Register a protocol factory associated with the given scheme. The factory |
| 40 // parameter may be null to clear any existing association. Returns the | 52 // parameter may be null to clear any existing association. Returns the |
| 41 // previously registered protocol factory if any. | 53 // previously registered protocol factory if any. |
| 42 URLRequest::ProtocolFactory* RegisterProtocolFactory( | 54 URLRequest::ProtocolFactory* RegisterProtocolFactory( |
| 43 const std::string& scheme, URLRequest::ProtocolFactory* factory); | 55 const std::string& scheme, URLRequest::ProtocolFactory* factory); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // check back on. | 94 // check back on. |
| 83 return true; | 95 return true; |
| 84 #endif | 96 #endif |
| 85 } | 97 } |
| 86 #endif | 98 #endif |
| 87 | 99 |
| 88 DISALLOW_EVIL_CONSTRUCTORS(URLRequestJobManager); | 100 DISALLOW_EVIL_CONSTRUCTORS(URLRequestJobManager); |
| 89 }; | 101 }; |
| 90 | 102 |
| 91 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H__ | 103 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H__ |
| OLD | NEW |