OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 #import "ios/net/clients/crn_forwarding_network_client.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/threading/thread_checker.h" |
| 10 |
| 11 @implementation CRNForwardingNetworkClient { |
| 12 // Next client in the client chain. |
| 13 base::scoped_nsprotocol<id<CRNNetworkClientProtocol>> _underlyingClient; |
| 14 base::ThreadChecker _threadChecker; |
| 15 } |
| 16 |
| 17 #pragma mark CRNNetworkClientProtocol methods |
| 18 |
| 19 - (void)didFailWithNSErrorCode:(NSInteger)nsErrorCode |
| 20 netErrorCode:(int)netErrorCode { |
| 21 DCHECK(_threadChecker.CalledOnValidThread()); |
| 22 DCHECK(_underlyingClient); |
| 23 [_underlyingClient didFailWithNSErrorCode:nsErrorCode |
| 24 netErrorCode:netErrorCode]; |
| 25 } |
| 26 |
| 27 - (void)didLoadData:(NSData*)data { |
| 28 DCHECK(_threadChecker.CalledOnValidThread()); |
| 29 DCHECK(_underlyingClient); |
| 30 [_underlyingClient didLoadData:data]; |
| 31 } |
| 32 |
| 33 - (void)didReceiveResponse:(NSURLResponse*)response { |
| 34 DCHECK(_threadChecker.CalledOnValidThread()); |
| 35 DCHECK(_underlyingClient); |
| 36 [_underlyingClient didReceiveResponse:response]; |
| 37 } |
| 38 |
| 39 - (void)wasRedirectedToRequest:(NSURLRequest*)request |
| 40 nativeRequest:(net::URLRequest*)nativeRequest |
| 41 redirectResponse:(NSURLResponse*)response { |
| 42 DCHECK(_threadChecker.CalledOnValidThread()); |
| 43 DCHECK(_underlyingClient); |
| 44 [_underlyingClient wasRedirectedToRequest:request |
| 45 nativeRequest:nativeRequest |
| 46 redirectResponse:response]; |
| 47 } |
| 48 |
| 49 - (void)didFinishLoading { |
| 50 DCHECK(_threadChecker.CalledOnValidThread()); |
| 51 DCHECK(_underlyingClient); |
| 52 [_underlyingClient didFinishLoading]; |
| 53 } |
| 54 |
| 55 - (void)didCreateNativeRequest:(net::URLRequest*)nativeRequest { |
| 56 DCHECK(_threadChecker.CalledOnValidThread()); |
| 57 DCHECK(_underlyingClient); |
| 58 [_underlyingClient didCreateNativeRequest:nativeRequest]; |
| 59 } |
| 60 |
| 61 - (void)didRecieveAuthChallenge:(net::AuthChallengeInfo*)authInfo |
| 62 nativeRequest:(const net::URLRequest&)nativeRequest |
| 63 callback:(const network_client::AuthCallback&)callback { |
| 64 DCHECK(_threadChecker.CalledOnValidThread()); |
| 65 DCHECK(_underlyingClient); |
| 66 [_underlyingClient didRecieveAuthChallenge:authInfo |
| 67 nativeRequest:nativeRequest |
| 68 callback:callback]; |
| 69 } |
| 70 |
| 71 - (void)cancelAuthRequest { |
| 72 DCHECK(_threadChecker.CalledOnValidThread()); |
| 73 DCHECK(_underlyingClient); |
| 74 [_underlyingClient cancelAuthRequest]; |
| 75 } |
| 76 |
| 77 - (id<CRNNetworkClientProtocol>)underlyingClient { |
| 78 return _underlyingClient; |
| 79 } |
| 80 |
| 81 - (void)setUnderlyingClient:(id<CRNNetworkClientProtocol>)underlyingClient { |
| 82 DCHECK(_threadChecker.CalledOnValidThread()); |
| 83 DCHECK(underlyingClient); |
| 84 _underlyingClient.reset([underlyingClient retain]); |
| 85 } |
| 86 |
| 87 @end |
OLD | NEW |