| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 5 #ifndef CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| 6 #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 6 #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // In order to work with Chrome resource loading IPC, it is desirable to | 40 // In order to work with Chrome resource loading IPC, it is desirable to |
| 41 // reclaim data in FIFO order in a RequestPeer in terms of performance. | 41 // reclaim data in FIFO order in a RequestPeer in terms of performance. |
| 42 // |payload|, |length|, |encoded_data_length| and |encoded_body_length| | 42 // |payload|, |length|, |encoded_data_length| and |encoded_body_length| |
| 43 // functions are thread-safe, but the data object itself must be destroyed on | 43 // functions are thread-safe, but the data object itself must be destroyed on |
| 44 // the original thread. | 44 // the original thread. |
| 45 class CONTENT_EXPORT ReceivedData { | 45 class CONTENT_EXPORT ReceivedData { |
| 46 public: | 46 public: |
| 47 virtual ~ReceivedData() {} | 47 virtual ~ReceivedData() {} |
| 48 virtual const char* payload() const = 0; | 48 virtual const char* payload() const = 0; |
| 49 virtual int length() const = 0; | 49 virtual int length() const = 0; |
| 50 // The encoded_data_length is the length of the encoded data transferred | |
| 51 // over the network, including headers. It is only set for responses | |
| 52 // originating from the network (ie. not the cache). It will usually be | |
| 53 // different from length(), and may be smaller if the content was | |
| 54 // compressed. -1 means this value is unavailable. | |
| 55 virtual int encoded_data_length() const = 0; | |
| 56 }; | 50 }; |
| 57 | 51 |
| 58 // A ThreadSafeReceivedData can be deleted on ANY thread. | 52 // A ThreadSafeReceivedData can be deleted on ANY thread. |
| 59 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; | 53 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; |
| 60 | 54 |
| 61 // Called as upload progress is made. | 55 // Called as upload progress is made. |
| 62 // note: only for requests with upload progress enabled. | 56 // note: only for requests with upload progress enabled. |
| 63 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; | 57 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; |
| 64 | 58 |
| 65 // Called when a redirect occurs. The implementation may return false to | 59 // Called when a redirect occurs. The implementation may return false to |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 // that case, OnReceivedData will not be called. | 73 // that case, OnReceivedData will not be called. |
| 80 // The encoded_data_length is the length of the encoded data transferred | 74 // The encoded_data_length is the length of the encoded data transferred |
| 81 // over the network, which could be different from data length (e.g. for | 75 // over the network, which could be different from data length (e.g. for |
| 82 // gzipped content). | 76 // gzipped content). |
| 83 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; | 77 virtual void OnDownloadedData(int len, int encoded_data_length) = 0; |
| 84 | 78 |
| 85 // Called when a chunk of response data is available. This method may | 79 // Called when a chunk of response data is available. This method may |
| 86 // be called multiple times or not at all if an error occurs. | 80 // be called multiple times or not at all if an error occurs. |
| 87 virtual void OnReceivedData(std::unique_ptr<ReceivedData> data) = 0; | 81 virtual void OnReceivedData(std::unique_ptr<ReceivedData> data) = 0; |
| 88 | 82 |
| 83 // Called when the transfer size is updated. This method may be called |
| 84 // multiple times or not at all. The transfer size is the length of the |
| 85 // response (including both headers and the body) over the network. |
| 86 // |transfer_size_diff| is the difference from the value previously reported |
| 87 // one (including the one in OnReceivedResponse). It must be positive. |
| 88 virtual void OnTransferSizeUpdated(int transfer_size_diff) = 0; |
| 89 |
| 89 // Called when metadata generated by the renderer is retrieved from the | 90 // Called when metadata generated by the renderer is retrieved from the |
| 90 // cache. This method may be called zero or one times. | 91 // cache. This method may be called zero or one times. |
| 91 virtual void OnReceivedCachedMetadata(const char* data, int len) {} | 92 virtual void OnReceivedCachedMetadata(const char* data, int len) {} |
| 92 | 93 |
| 93 // Called when the response is complete. This method signals completion of | 94 // Called when the response is complete. This method signals completion of |
| 94 // the resource load. | 95 // the resource load. |
| 95 virtual void OnCompletedRequest(int error_code, | 96 virtual void OnCompletedRequest(int error_code, |
| 96 bool was_ignored_by_handler, | 97 bool was_ignored_by_handler, |
| 97 bool stale_copy_in_cache, | 98 bool stale_copy_in_cache, |
| 98 const base::TimeTicks& completion_time, | 99 const base::TimeTicks& completion_time, |
| 99 int64_t total_transfer_size, | 100 int64_t total_transfer_size, |
| 100 int64_t encoded_body_size) = 0; | 101 int64_t encoded_body_size) = 0; |
| 101 | 102 |
| 102 virtual ~RequestPeer() {} | 103 virtual ~RequestPeer() {} |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace content | 106 } // namespace content |
| 106 | 107 |
| 107 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 108 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| OLD | NEW |