| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 IOS_NET_REQUEST_TRACKER_H_ | 5 #ifndef IOS_NET_REQUEST_TRACKER_H_ |
| 6 #define IOS_NET_REQUEST_TRACKER_H_ | 6 #define IOS_NET_REQUEST_TRACKER_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 base::WeakPtr<RequestTracker> GetWeakPtr(); | 72 base::WeakPtr<RequestTracker> GetWeakPtr(); |
| 73 | 73 |
| 74 // This function has to be called before using the tracker. | 74 // This function has to be called before using the tracker. |
| 75 virtual void Init(); | 75 virtual void Init(); |
| 76 | 76 |
| 77 // Add a factory that may create network clients for requests going through | 77 // Add a factory that may create network clients for requests going through |
| 78 // this tracker. | 78 // this tracker. |
| 79 void AddNetworkClientFactory(CRNForwardingNetworkClientFactory* factory); | 79 void AddNetworkClientFactory(CRNForwardingNetworkClientFactory* factory); |
| 80 | 80 |
| 81 // Registers a factory with the class that will be added to all trackers. | |
| 82 // Requests without associated trackers can add clients from these factories | |
| 83 // using GlobalClientsHandlingAnyRequest(). | |
| 84 // Only |-clientHandlingAnyRequest| will be called on |factory|, the other | |
| 85 // methods are not supported. | |
| 86 static void AddGlobalNetworkClientFactory( | |
| 87 CRNForwardingNetworkClientFactory* factory); | |
| 88 | |
| 89 // Gets the request context associated with the tracker. | 81 // Gets the request context associated with the tracker. |
| 90 virtual URLRequestContext* GetRequestContext() = 0; | 82 virtual URLRequestContext* GetRequestContext() = 0; |
| 91 | 83 |
| 92 // Network client generation methods. All of these four ClientsHandling... | 84 // Network client generation methods. All of these four ClientsHandling... |
| 93 // methods return an array of CRNForwardingNetworkClient instances, according | 85 // methods return an array of CRNForwardingNetworkClient instances, according |
| 94 // to the CRNForwardingNetworkClientFactories added to the tracker. The array | 86 // to the CRNForwardingNetworkClientFactories added to the tracker. The array |
| 95 // may be empty. The caller is responsible for taking ownership of the clients | 87 // may be empty. The caller is responsible for taking ownership of the clients |
| 96 // in the array. | 88 // in the array. |
| 97 | 89 |
| 98 // Static method that returns clients that can handle any request, for use | |
| 99 // in cases where a request isn't associated with any request_tracker. | |
| 100 static NSArray* GlobalClientsHandlingAnyRequest(); | |
| 101 | |
| 102 // Returns clients that can handle any request. | 90 // Returns clients that can handle any request. |
| 103 NSArray* ClientsHandlingAnyRequest(); | 91 NSArray* ClientsHandlingAnyRequest(); |
| 104 // Returns clients that can handle |request|. | 92 // Returns clients that can handle |request|. |
| 105 NSArray* ClientsHandlingRequest(const URLRequest& request); | 93 NSArray* ClientsHandlingRequest(const URLRequest& request); |
| 106 // Returns clients that can handle |request| with |response|. | 94 // Returns clients that can handle |request| with |response|. |
| 107 NSArray* ClientsHandlingRequestAndResponse(const URLRequest& request, | 95 NSArray* ClientsHandlingRequestAndResponse(const URLRequest& request, |
| 108 NSURLResponse* response); | 96 NSURLResponse* response); |
| 109 // Returns clients that can handle a redirect of |request| to |new_url| based | 97 // Returns clients that can handle a redirect of |request| to |new_url| based |
| 110 // on |redirect_response|. | 98 // on |redirect_response|. |
| 111 NSArray* ClientsHandlingRedirect(const URLRequest& request, | 99 NSArray* ClientsHandlingRedirect(const URLRequest& request, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool initialized_; | 153 bool initialized_; |
| 166 CacheMode cache_mode_; | 154 CacheMode cache_mode_; |
| 167 base::ThreadChecker thread_checker_; | 155 base::ThreadChecker thread_checker_; |
| 168 | 156 |
| 169 base::WeakPtrFactory<RequestTracker> weak_ptr_factory_; | 157 base::WeakPtrFactory<RequestTracker> weak_ptr_factory_; |
| 170 }; | 158 }; |
| 171 | 159 |
| 172 } // namespace net | 160 } // namespace net |
| 173 | 161 |
| 174 #endif // IOS_NET_REQUEST_TRACKER_H_ | 162 #endif // IOS_NET_REQUEST_TRACKER_H_ |
| OLD | NEW |