| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 class WebURLLoader; | 39 class WebURLLoader; |
| 40 class WebURLRequest; | 40 class WebURLRequest; |
| 41 class WebURLResponse; | 41 class WebURLResponse; |
| 42 struct WebURLError; | 42 struct WebURLError; |
| 43 | 43 |
| 44 class BLINK_PLATFORM_EXPORT WebURLLoaderClient { | 44 class BLINK_PLATFORM_EXPORT WebURLLoaderClient { |
| 45 public: | 45 public: |
| 46 // Called when following a redirect. |newRequest| contains the request | 46 // Called when following a redirect. |newRequest| contains the request |
| 47 // generated by the redirect. The client may modify |newRequest|. | 47 // generated by the redirect. The client may modify |newRequest|. |
| 48 // |encodedDataLength| is the size of the data that came from the network |
| 49 // for this redirect, or zero if the redirect was served from cache. |
| 48 virtual void willFollowRedirect( | 50 virtual void willFollowRedirect( |
| 49 WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirect
Response) { } | 51 WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirect
Response, int64_t encodedDataLength) {} |
| 50 | 52 |
| 51 // Called to report upload progress. The bytes reported correspond to | 53 // Called to report upload progress. The bytes reported correspond to |
| 52 // the HTTP message body. | 54 // the HTTP message body. |
| 53 virtual void didSendData( | 55 virtual void didSendData( |
| 54 WebURLLoader*, unsigned long long bytesSent, unsigned long long totalByt
esToBeSent) { } | 56 WebURLLoader*, unsigned long long bytesSent, unsigned long long totalByt
esToBeSent) { } |
| 55 | 57 |
| 56 // Called when response headers are received. | 58 // Called when response headers are received. |
| 57 virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&) { } | 59 virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&) { } |
| 58 | 60 |
| 59 // Called when response headers are received. | 61 // Called when response headers are received. |
| 60 // The ownership of |handle| is transferred to the callee. | 62 // The ownership of |handle| is transferred to the callee. |
| 61 virtual void didReceiveResponse(WebURLLoader* loader, const WebURLResponse&
response, WebDataConsumerHandle* handle) | 63 virtual void didReceiveResponse(WebURLLoader* loader, const WebURLResponse&
response, WebDataConsumerHandle* handle) |
| 62 { | 64 { |
| 63 delete handle; | 65 delete handle; |
| 64 didReceiveResponse(loader, response); | 66 didReceiveResponse(loader, response); |
| 65 } | 67 } |
| 66 | 68 |
| 67 // Called when a chunk of response data is downloaded. This is only called | 69 // Called when a chunk of response data is downloaded. This is only called |
| 68 // if WebURLRequest's downloadToFile flag was set to true. | 70 // if WebURLRequest's downloadToFile flag was set to true. |
| 69 virtual void didDownloadData(WebURLLoader*, int dataLength, int encodedDataL
ength) { } | 71 virtual void didDownloadData(WebURLLoader*, int dataLength, int encodedDataL
ength) { } |
| 70 | 72 |
| 71 // Called when a chunk of response data is received. | 73 // Called when a chunk of response data is received. |dataLength| is the |
| 72 virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength,
int encodedDataLength) { } | 74 // number of bytes pointed to by |data|. |encodedDataLength| is the number |
| 75 // of bytes actually received from network to serve this chunk, including |
| 76 // HTTP headers and framing if relevant. It is 0 if the response was served |
| 77 // from cache, and -1 if this information is unavailable. |
| 78 // TODO(ricea): -1 is problematic for consumers maintaining a running |
| 79 // total. Investigate using 0 for all unavailable cases. |
| 80 // |encodedBodyLength| is the number of bytes used to store this chunk, |
| 81 // possibly encrypted, excluding headers or framing. It is set even if the |
| 82 // response was served from cache. |
| 83 virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength,
int encodedDataLength, int encodedBodyLength) {} |
| 73 | 84 |
| 74 // Called when a chunk of renderer-generated metadata is received from the c
ache. | 85 // Called when a chunk of renderer-generated metadata is received from the c
ache. |
| 75 virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int d
ataLength) { } | 86 virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int d
ataLength) { } |
| 76 | 87 |
| 77 // Called when the load completes successfully. | 88 // Called when the load completes successfully. |
| 78 // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. | 89 // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. |
| 79 virtual void didFinishLoading(WebURLLoader* loader, double finishTime, int64
_t totalEncodedDataLength) { } | 90 virtual void didFinishLoading(WebURLLoader* loader, double finishTime, int64
_t totalEncodedDataLength) { } |
| 80 | 91 |
| 81 // Called when the load completes with an error. | 92 // Called when the load completes with an error. |
| 82 virtual void didFail(WebURLLoader*, const WebURLError&) { } | 93 virtual void didFail(WebURLLoader*, const WebURLError&) { } |
| 83 | 94 |
| 84 // Value passed to didFinishLoading when total encoded data length isn't kno
wn. | 95 // Value passed to didFinishLoading when total encoded data length isn't kno
wn. |
| 85 static const int64_t kUnknownEncodedDataLength = -1; | 96 static const int64_t kUnknownEncodedDataLength = -1; |
| 86 | 97 |
| 87 protected: | 98 protected: |
| 88 virtual ~WebURLLoaderClient() { } | 99 virtual ~WebURLLoaderClient() { } |
| 89 }; | 100 }; |
| 90 | 101 |
| 91 } // namespace blink | 102 } // namespace blink |
| 92 | 103 |
| 93 #endif | 104 #endif |
| OLD | NEW |