Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: net/url_request/url_request_job_manager.h

Issue 6730034: Remove all "net::" prefixes under net/url_request for code that's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed indentation Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_job_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/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 namespace net { 19 namespace net {
20 20
21 // This class is responsible for managing the set of protocol factories and 21 // This class is responsible for managing the set of protocol factories and
22 // request interceptors that determine how an net::URLRequestJob gets created to 22 // request interceptors that determine how an URLRequestJob gets created to
23 // handle an net::URLRequest. 23 // handle an URLRequest.
24 // 24 //
25 // MULTI-THREADING NOTICE: 25 // MULTI-THREADING NOTICE:
26 // net::URLRequest is designed to have all consumers on a single thread, and 26 // URLRequest is designed to have all consumers on a single thread, and
27 // so no attempt is made to support ProtocolFactory or Interceptor instances 27 // so no attempt is made to support ProtocolFactory or Interceptor instances
28 // being registered/unregistered or in any way poked on multiple threads. 28 // being registered/unregistered or in any way poked on multiple threads.
29 // However, we do support checking for supported schemes FROM ANY THREAD 29 // However, we do support checking for supported schemes FROM ANY THREAD
30 // (i.e., it is safe to call SupportsScheme on any thread). 30 // (i.e., it is safe to call SupportsScheme on any thread).
31 // 31 //
32 class URLRequestJobManager { 32 class URLRequestJobManager {
33 public: 33 public:
34 // Returns the singleton instance. 34 // Returns the singleton instance.
35 static URLRequestJobManager* GetInstance(); 35 static URLRequestJobManager* GetInstance();
36 36
37 // Instantiate an net::URLRequestJob implementation based on the registered 37 // Instantiate an URLRequestJob implementation based on the registered
38 // interceptors and protocol factories. This will always succeed in 38 // interceptors and protocol factories. This will always succeed in
39 // returning a job unless we are--in the extreme case--out of memory. 39 // returning a job unless we are--in the extreme case--out of memory.
40 net::URLRequestJob* CreateJob(net::URLRequest* request) const; 40 URLRequestJob* CreateJob(URLRequest* request) const;
41 41
42 // Allows interceptors to hijack the request after examining the new location 42 // Allows interceptors to hijack the request after examining the new location
43 // of a redirect. Returns NULL if no interceptor intervenes. 43 // of a redirect. Returns NULL if no interceptor intervenes.
44 net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request, 44 URLRequestJob* MaybeInterceptRedirect(URLRequest* request,
45 const GURL& location) const; 45 const GURL& location) const;
46 46
47 // Allows interceptors to hijack the request after examining the response 47 // Allows interceptors to hijack the request after examining the response
48 // status and headers. This is also called when there is no server response 48 // status and headers. This is also called when there is no server response
49 // at all to allow interception of failed requests due to network errors. 49 // at all to allow interception of failed requests due to network errors.
50 // Returns NULL if no interceptor intervenes. 50 // Returns NULL if no interceptor intervenes.
51 net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request) const; 51 URLRequestJob* MaybeInterceptResponse(URLRequest* request) const;
52 52
53 // Returns true if there is a protocol factory registered for the given 53 // Returns true if there is a protocol factory registered for the given
54 // scheme. Note: also returns true if there is a built-in handler for the 54 // scheme. Note: also returns true if there is a built-in handler for the
55 // given scheme. 55 // given scheme.
56 bool SupportsScheme(const std::string& scheme) const; 56 bool SupportsScheme(const std::string& scheme) const;
57 57
58 // Register a protocol factory associated with the given scheme. The factory 58 // Register a protocol factory associated with the given scheme. The factory
59 // parameter may be null to clear any existing association. Returns the 59 // parameter may be null to clear any existing association. Returns the
60 // previously registered protocol factory if any. 60 // previously registered protocol factory if any.
61 net::URLRequest::ProtocolFactory* RegisterProtocolFactory( 61 URLRequest::ProtocolFactory* RegisterProtocolFactory(
62 const std::string& scheme, net::URLRequest::ProtocolFactory* factory); 62 const std::string& scheme, URLRequest::ProtocolFactory* factory);
63 63
64 // Register/unregister a request interceptor. 64 // Register/unregister a request interceptor.
65 void RegisterRequestInterceptor(net::URLRequest::Interceptor* interceptor); 65 void RegisterRequestInterceptor(URLRequest::Interceptor* interceptor);
66 void UnregisterRequestInterceptor(net::URLRequest::Interceptor* interceptor); 66 void UnregisterRequestInterceptor(URLRequest::Interceptor* interceptor);
67 67
68 void set_enable_file_access(bool enable) { enable_file_access_ = enable; } 68 void set_enable_file_access(bool enable) { enable_file_access_ = enable; }
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, URLRequest::ProtocolFactory*> FactoryMap;
73 typedef std::vector<net::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 79 #ifndef NDEBUG
80 // 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
81 // avoid needing to define that thread externally. Since we expect all 81 // 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 82 // callers to be on the same thread, we don't worry about threads racing to
83 // set the allowed thread. 83 // set the allowed thread.
(...skipping 27 matching lines...) Expand all
111 FactoryMap factories_; 111 FactoryMap factories_;
112 InterceptorList interceptors_; 112 InterceptorList interceptors_;
113 bool enable_file_access_; 113 bool enable_file_access_;
114 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_
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_job_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698