crn_network_client_protocol.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  3. // found in the LICENSE file.
  4. #ifndef IOS_NET_CLIENTS_CRN_NETWORK_CLIENT_PROTOCOL_H_
  5. #define IOS_NET_CLIENTS_CRN_NETWORK_CLIENT_PROTOCOL_H_
  6. #import <Foundation/Foundation.h>
  7. #include "base/strings/string_util.h"
  8. namespace net {
  9. class AuthChallengeInfo;
  10. class URLRequest;
  11. } // namespace net
  12. // CRNNetworkClientProtocol provides an interface for delegate classes that
  13. // receive calls about data loading from the Chromium network stack.
  14. // Many methods in this protocol correspond to the NSURLProtocol methods, and
  15. // are called by the HttpProtocolHandlerCore when events occur in the network
  16. // stack. A class that implements this protocol can respond by proxying the call
  17. // over to an NSURLProtocolClient that it manages, or by managing the data as it
  18. // sees fit.
  19. @protocol CRNNetworkClientProtocol<NSObject>
  20. // Methods corresponding to NSURLProtocolClient methods.
  21. // Called from the IO thread.
  22. // Corresponds to |-URLProtocol:didFailWithError|.
  23. // The base client will create an NSError instance using |nsErrorCode| (an error
  24. // code from NSURLError.h) and |netErrorCode| (a Chrome errror code) and url
  25. // and creation time information supplied by the HttpProtocolHandlerCore
  26. // instance.
  27. - (void)didFailWithNSErrorCode:(NSInteger)nsErrorCode
  28. netErrorCode:(int)netErrorCode;
  29. // Corresponds to |-URLProtocol:didLoadData|.
  30. - (void)didLoadData:(NSData*)data;
  31. // Corresponds to |-URLProtocol:didReceiveResponse:cacheStoragePolicy|.
  32. - (void)didReceiveResponse:(NSURLResponse*)response;
  33. // Corresponds to |-URLProtocol:wasRedirectedToRequest:redirectResponse|.
  34. - (void)wasRedirectedToRequest:(NSURLRequest*)request
  35. nativeRequest:(net::URLRequest*)nativeRequest
  36. redirectResponse:(NSURLResponse*)redirectResponse;
  37. // Corresponds to |-URLProtocol:didFinishLoading|.
  38. - (void)didFinishLoading;
  39. // Methods that don't correspond to NSURLProtocolClient methdods but which are
  40. // used to implement injectible features using network clients.
  41. // Called after |nativeRequest| is created, but before it's started; native
  42. // clients have the opportunity to modify the request at this time.
  43. - (void)didCreateNativeRequest:(net::URLRequest*)nativeRequest;
  44. @end
  45. #endif // IOS_NET_CLIENTS_CRN_NETWORK_CLIENT_PROTOCOL_H_