| 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 19 matching lines...) Expand all  Loading... | 
|   30  |   30  | 
|   31 #ifndef WebURLLoaderClient_h |   31 #ifndef WebURLLoaderClient_h | 
|   32 #define WebURLLoaderClient_h |   32 #define WebURLLoaderClient_h | 
|   33  |   33  | 
|   34 #include "public/platform/WebCommon.h" |   34 #include "public/platform/WebCommon.h" | 
|   35 #include "public/platform/WebDataConsumerHandle.h" |   35 #include "public/platform/WebDataConsumerHandle.h" | 
|   36 #include <memory> |   36 #include <memory> | 
|   37  |   37  | 
|   38 namespace blink { |   38 namespace blink { | 
|   39  |   39  | 
|   40 class WebURLLoader; |  | 
|   41 class WebURLRequest; |   40 class WebURLRequest; | 
|   42 class WebURLResponse; |   41 class WebURLResponse; | 
|   43 struct WebURLError; |   42 struct WebURLError; | 
|   44  |   43  | 
|   45 class BLINK_PLATFORM_EXPORT WebURLLoaderClient { |   44 class BLINK_PLATFORM_EXPORT WebURLLoaderClient { | 
|   46  public: |   45  public: | 
|   47   // Called when following a redirect. |newRequest| contains the request |   46   // Called when following a redirect. |newRequest| contains the request | 
|   48   // generated by the redirect. The client may modify |newRequest|. |   47   // generated by the redirect. The client may modify |newRequest|. | 
|   49   // |encodedDataLength| is the size of the data that came from the network |   48   // |encodedDataLength| is the size of the data that came from the network | 
|   50   // for this redirect, or zero if the redirect was served from cache. |   49   // for this redirect, or zero if the redirect was served from cache. | 
|   51   // |   50   // | 
|   52   // Implementations should return true to instruct the loader to follow the, |   51   // Implementations should return true to instruct the loader to follow the, | 
|   53   // redirect, or false otherwise. |   52   // redirect, or false otherwise. | 
|   54   virtual bool willFollowRedirect(WebURLLoader*, |   53   virtual bool willFollowRedirect(WebURLRequest& newRequest, | 
|   55                                   WebURLRequest& newRequest, |  | 
|   56                                   const WebURLResponse& redirectResponse) { |   54                                   const WebURLResponse& redirectResponse) { | 
|   57     return true; |   55     return true; | 
|   58   } |   56   } | 
|   59  |   57  | 
|   60   // Called to report upload progress. The bytes reported correspond to |   58   // Called to report upload progress. The bytes reported correspond to | 
|   61   // the HTTP message body. |   59   // the HTTP message body. | 
|   62   virtual void didSendData(WebURLLoader*, |   60   virtual void didSendData(unsigned long long bytesSent, | 
|   63                            unsigned long long bytesSent, |  | 
|   64                            unsigned long long totalBytesToBeSent) {} |   61                            unsigned long long totalBytesToBeSent) {} | 
|   65  |   62  | 
|   66   // Called when response headers are received. |   63   // Called when response headers are received. | 
|   67   virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&) {} |   64   virtual void didReceiveResponse(const WebURLResponse&) {} | 
|   68  |   65  | 
|   69   // Called when response headers are received. |   66   // Called when response headers are received. | 
|   70   virtual void didReceiveResponse( |   67   virtual void didReceiveResponse( | 
|   71       WebURLLoader* loader, |  | 
|   72       const WebURLResponse& response, |   68       const WebURLResponse& response, | 
|   73       std::unique_ptr<WebDataConsumerHandle> handle) { |   69       std::unique_ptr<WebDataConsumerHandle> handle) { | 
|   74     didReceiveResponse(loader, response); |   70     didReceiveResponse(response); | 
|   75   } |   71   } | 
|   76  |   72  | 
|   77   // Called when a chunk of response data is downloaded. This is only called |   73   // Called when a chunk of response data is downloaded. This is only called | 
|   78   // if WebURLRequest's downloadToFile flag was set to true. |   74   // if WebURLRequest's downloadToFile flag was set to true. | 
|   79   virtual void didDownloadData(WebURLLoader*, |   75   virtual void didDownloadData(int dataLength, int encodedDataLength) {} | 
|   80                                int dataLength, |  | 
|   81                                int encodedDataLength) {} |  | 
|   82  |   76  | 
|   83   // Called when a chunk of response data is received. |dataLength| is the |   77   // Called when a chunk of response data is received. |dataLength| is the | 
|   84   // number of bytes pointed to by |data|. |encodedDataLength| is the number |   78   // number of bytes pointed to by |data|. |encodedDataLength| is the number | 
|   85   // of bytes actually received from network to serve this chunk, including |   79   // of bytes actually received from network to serve this chunk, including | 
|   86   // HTTP headers and framing if relevant. It is 0 if the response was served |   80   // HTTP headers and framing if relevant. It is 0 if the response was served | 
|   87   // from cache, and -1 if this information is unavailable. |   81   // from cache, and -1 if this information is unavailable. | 
|   88   // TODO(ricea): -1 is problematic for consumers maintaining a running |   82   // TODO(ricea): -1 is problematic for consumers maintaining a running | 
|   89   //     total. Investigate using 0 for all unavailable cases. |   83   //     total. Investigate using 0 for all unavailable cases. | 
|   90   virtual void didReceiveData(WebURLLoader*, |   84   virtual void didReceiveData(const char* data, | 
|   91                               const char* data, |  | 
|   92                               int dataLength, |   85                               int dataLength, | 
|   93                               int encodedDataLength) {} |   86                               int encodedDataLength) {} | 
|   94  |   87  | 
|   95   // Called when a chunk of renderer-generated metadata is received from the |   88   // Called when a chunk of renderer-generated metadata is received from the | 
|   96   // cache. |   89   // cache. | 
|   97   virtual void didReceiveCachedMetadata(WebURLLoader*, |   90   virtual void didReceiveCachedMetadata(const char* data, int dataLength) {} | 
|   98                                         const char* data, |  | 
|   99                                         int dataLength) {} |  | 
|  100  |   91  | 
|  101   // Called when the load completes successfully. |   92   // Called when the load completes successfully. | 
|  102   // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. |   93   // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. | 
|  103   virtual void didFinishLoading(WebURLLoader* loader, |   94   virtual void didFinishLoading(double finishTime, | 
|  104                                 double finishTime, |  | 
|  105                                 int64_t totalEncodedDataLength, |   95                                 int64_t totalEncodedDataLength, | 
|  106                                 int64_t totalEncodedBodyLength) {} |   96                                 int64_t totalEncodedBodyLength) {} | 
|  107  |   97  | 
|  108   // Called when the load completes with an error. |   98   // Called when the load completes with an error. | 
|  109   // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. |   99   // |totalEncodedDataLength| may be equal to kUnknownEncodedDataLength. | 
|  110   virtual void didFail(WebURLLoader*, |  100   virtual void didFail(const WebURLError&, | 
|  111                        const WebURLError&, |  | 
|  112                        int64_t totalEncodedDataLength, |  101                        int64_t totalEncodedDataLength, | 
|  113                        int64_t totalEncodedBodyLength) {} |  102                        int64_t totalEncodedBodyLength) {} | 
|  114  |  103  | 
|  115   // Value passed to didFinishLoading when total encoded data length isn't |  104   // Value passed to didFinishLoading when total encoded data length isn't | 
|  116   // known. |  105   // known. | 
|  117   static const int64_t kUnknownEncodedDataLength = -1; |  106   static const int64_t kUnknownEncodedDataLength = -1; | 
|  118  |  107  | 
|  119  protected: |  108  protected: | 
|  120   virtual ~WebURLLoaderClient() {} |  109   virtual ~WebURLLoaderClient() {} | 
|  121 }; |  110 }; | 
|  122  |  111  | 
|  123 }  // namespace blink |  112 }  // namespace blink | 
|  124  |  113  | 
|  125 #endif |  114 #endif | 
| OLD | NEW |