Add ICU message format support
[chromium-blink-merge.git] / ios / net / clients / crn_forwarding_network_client_factory.h
blob4a6ff4795a6efdcc3dea5f277abfb2e5a36ad1b1
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.
5 #ifndef IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_
6 #define IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_
8 #import <Foundation/Foundation.h>
10 @class CRNForwardingNetworkClient;
11 class GURL;
13 namespace net {
14 class URLRequest;
17 // Abstract factory that creates CRNForwardingNetworkClient instances.
18 @interface CRNForwardingNetworkClientFactory : NSObject
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.
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.
29 // TODO(marq): Investigate possible less bloated interfaces for this, where (for
30 // example) all clients are added to each request, and then the clients opt-out
31 // during the existing CRNNetworkClientProtocol calls.
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;
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;
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;
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;
61 // Subclasses must implement this method.
62 // Only used in debug, to check that the ordering is consistent.
63 - (Class)clientClass;
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;
70 // YES if this factory may require an array of factories to be ordered.
71 - (BOOL)requiresOrdering;
73 // YES if the mustApply rules on this class aren't cyclic. Exposed for testing.
74 + (BOOL)orderedOK;
76 // Comparison function to sort a list of factories.
77 - (NSComparisonResult)orderRelativeTo:
78 (CRNForwardingNetworkClientFactory*)factory;
80 @end
82 #endif // IOS_NET_CLIENTS_CRN_FORWARDING_NETWORK_CLIENT_FACTORY_H_