Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_ | |
| 6 #define IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 | |
| 10 @class CRNForwardingNetworkClient; | |
| 11 class GURL; | |
| 12 | |
| 13 namespace net { | |
| 14 class URLRequest; | |
| 15 } | |
| 16 | |
| 17 // Abstract factory that creates CRNForwardingNetworkClient instances. | |
| 18 @interface CRNForwardingNetworkClientFactory : NSObject | |
| 19 | |
| 20 // Any subclass of CRNForwardingNetworkClientFactory should implement exactly | |
| 21 // one of the clientHandling... methods. Each method either returns an network | |
| 22 // client, or nil if the request in question isn't eligible for handling | |
| 23 // by the factory's clients. A unit test verifies that all subclasses override | |
| 24 // one of these methods. | |
| 25 | |
| 26 // The expectation is that subclasses of this class will not be derived from; | |
| 27 // if this becomes necessary, the unit tests for this class should be updated. | |
| 28 | |
| 29 // TODO(marq): Investigate possible less bloated interfaces for this, where (for | |
|
sdefresne
2015/03/10 17:00:44
nit: s/possible/possibly/
| |
| 30 // example) all clients are added to each request, and then the clients opt-out | |
| 31 // during the existing CRNNetworkClientProtocol calls. | |
| 32 | |
| 33 // Return a client to handle any request. | |
| 34 // Factories should implement this method only if their clients need to be able | |
| 35 // to handle didFailWithError: calls that might originate before the native | |
| 36 // request is generated | |
| 37 - (CRNForwardingNetworkClient*)clientHandlingAnyRequest; | |
| 38 | |
| 39 // Return a client to handle |request|. | |
| 40 // Factories should implement this method if their clients need to operate on | |
| 41 // the request before it is started (for example, by modifying headers). | |
| 42 - (CRNForwardingNetworkClient*) | |
| 43 clientHandlingRequest:(const net::URLRequest&)request; | |
| 44 | |
| 45 // Return a client to handle |request| and |response|. | |
| 46 // Factories should implement this method if their clients need to operate on | |
| 47 // non-redirected responses. | |
| 48 - (CRNForwardingNetworkClient*) | |
| 49 clientHandlingResponse:(NSURLResponse*)response | |
| 50 request:(const net::URLRequest&)request; | |
| 51 | |
| 52 // Returns a client to handle a redirect of |request| to |url| in response to | |
| 53 // |response|. | |
| 54 // Factories should only implement this method if their clients need to operate | |
| 55 // on redirects. | |
| 56 - (CRNForwardingNetworkClient*) | |
| 57 clientHandlingRedirect:(const net::URLRequest&)request | |
| 58 url:(const GURL&)url | |
| 59 response:(NSURLResponse*)response; | |
| 60 | |
| 61 // Subclasses must implement this method. | |
| 62 // Only used in debug, to check that the ordering is consistent. | |
| 63 - (Class)clientClass; | |
| 64 | |
| 65 // Class of another network client that this factory client class must be | |
| 66 // ordered before or after. Default is nil. | |
| 67 + (Class)mustApplyBefore; | |
| 68 + (Class)mustApplyAfter; | |
| 69 | |
| 70 // YES if this factory may require an array of factories to be ordered. | |
| 71 - (BOOL)requiresOrdering; | |
| 72 | |
| 73 // YES if the mustApply rules on this class aren't cyclic. Exposed for testing. | |
| 74 + (BOOL)orderedOK; | |
| 75 | |
| 76 // Comparison function to sort a list of factories. | |
| 77 - (NSComparisonResult)orderRelativeTo: | |
| 78 (CRNForwardingNetworkClientFactory*)factory; | |
| 79 | |
| 80 @end | |
| 81 | |
| 82 #endif // IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_ | |
| OLD | NEW |