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