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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/lock.h" | 13 #include "base/lock.h" |
14 #include "base/platform_thread.h" | 14 #include "base/platform_thread.h" |
15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
16 | 16 |
17 template <typename T> struct DefaultSingletonTraits; | 17 template <typename T> struct DefaultSingletonTraits; |
18 | 18 |
19 // This class is responsible for managing the set of protocol factories and | 19 // This class is responsible for managing the set of protocol factories and |
20 // request interceptors that determine how an URLRequestJob gets created to | 20 // request interceptors that determine how an net::URLRequestJob gets created to |
21 // handle an net::URLRequest. | 21 // handle an net::URLRequest. |
22 // | 22 // |
23 // MULTI-THREADING NOTICE: | 23 // MULTI-THREADING NOTICE: |
24 // net::URLRequest is designed to have all consumers on a single thread, and | 24 // net::URLRequest is designed to have all consumers on a single thread, and |
25 // so no attempt is made to support ProtocolFactory or Interceptor instances | 25 // so no attempt is made to support ProtocolFactory or Interceptor instances |
26 // being registered/unregistered or in any way poked on multiple threads. | 26 // being registered/unregistered or in any way poked on multiple threads. |
27 // However, we do support checking for supported schemes FROM ANY THREAD | 27 // However, we do support checking for supported schemes FROM ANY THREAD |
28 // (i.e., it is safe to call SupportsScheme on any thread). | 28 // (i.e., it is safe to call SupportsScheme on any thread). |
29 // | 29 // |
30 class URLRequestJobManager { | 30 class URLRequestJobManager { |
31 public: | 31 public: |
32 // Returns the singleton instance. | 32 // Returns the singleton instance. |
33 static URLRequestJobManager* GetInstance(); | 33 static URLRequestJobManager* GetInstance(); |
34 | 34 |
35 // Instantiate an URLRequestJob implementation based on the registered | 35 // Instantiate an net::URLRequestJob implementation based on the registered |
36 // interceptors and protocol factories. This will always succeed in | 36 // interceptors and protocol factories. This will always succeed in |
37 // returning a job unless we are--in the extreme case--out of memory. | 37 // returning a job unless we are--in the extreme case--out of memory. |
38 net::URLRequestJob* CreateJob(net::URLRequest* request) const; | 38 net::URLRequestJob* CreateJob(net::URLRequest* request) const; |
39 | 39 |
40 // Allows interceptors to hijack the request after examining the new location | 40 // Allows interceptors to hijack the request after examining the new location |
41 // of a redirect. Returns NULL if no interceptor intervenes. | 41 // of a redirect. Returns NULL if no interceptor intervenes. |
42 net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, | 42 net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, |
43 const GURL& location) const; | 43 const GURL& location) const; |
44 | 44 |
45 // Allows interceptors to hijack the request after examining the response | 45 // Allows interceptors to hijack the request after examining the response |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // check back on. | 107 // check back on. |
108 return true; | 108 return true; |
109 #endif | 109 #endif |
110 } | 110 } |
111 #endif | 111 #endif |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); | 113 DISALLOW_COPY_AND_ASSIGN(URLRequestJobManager); |
114 }; | 114 }; |
115 | 115 |
116 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H__ | 116 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_MANAGER_H__ |
OLD | NEW |