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 18 matching lines...) Expand all Loading... |
29 // This is implemented by our custom resource loader within content. The Peer | 29 // This is implemented by our custom resource loader within content. The Peer |
30 // and it's bridge should have identical lifetimes as they represent each end of | 30 // and it's bridge should have identical lifetimes as they represent each end of |
31 // a communication channel. | 31 // a communication channel. |
32 // | 32 // |
33 // These callbacks mirror net::URLRequest::Delegate and the order and | 33 // These callbacks mirror net::URLRequest::Delegate and the order and |
34 // conditions in which they will be called are identical. See url_request.h | 34 // conditions in which they will be called are identical. See url_request.h |
35 // for more information. | 35 // for more information. |
36 class CONTENT_EXPORT RequestPeer { | 36 class CONTENT_EXPORT RequestPeer { |
37 public: | 37 public: |
38 // This class represents data gotten from the Browser process. Each data | 38 // This class represents data gotten from the Browser process. Each data |
39 // consists of |payload|, |length| and |encoded_length|. The payload is | 39 // consists of |payload|, |length|, |encoded_data_length| and |
40 // valid only when the data instance is valid. | 40 // |encoded_body_length|. The payload is valid only when the data instance is |
| 41 // valid. |
41 // In order to work with Chrome resource loading IPC, it is desirable to | 42 // In order to work with Chrome resource loading IPC, it is desirable to |
42 // reclaim data in FIFO order in a RequestPeer in terms of performance. | 43 // reclaim data in FIFO order in a RequestPeer in terms of performance. |
43 // |payload|, |length| and |encoded_length| functions are thread-safe, but | 44 // |payload|, |length|, |encoded_data_length| and |encoded_body_length| |
44 // the data object itself must be destroyed on the original thread. | 45 // functions are thread-safe, but the data object itself must be destroyed on |
| 46 // the original thread. |
45 class CONTENT_EXPORT ReceivedData { | 47 class CONTENT_EXPORT ReceivedData { |
46 public: | 48 public: |
47 virtual ~ReceivedData() {} | 49 virtual ~ReceivedData() {} |
48 virtual const char* payload() const = 0; | 50 virtual const char* payload() const = 0; |
49 virtual int length() const = 0; | 51 virtual int length() const = 0; |
50 // The encoded_length is the length of the encoded data transferred | 52 // The encoded_data_length is the length of the encoded data transferred |
51 // over the network, which could be different from data length (e.g. for | 53 // over the network, including headers. It is only set for responses |
52 // gzipped content). | 54 // originating from the network (ie. not the cache). It will usually be |
53 virtual int encoded_length() const = 0; | 55 // different from length(), and may be smaller if the content was |
| 56 // compressed. -1 means this value is unavailable. |
| 57 virtual int encoded_data_length() const = 0; |
| 58 // The encoded_body_length is the size of the body as transferred over the |
| 59 // network or stored in the disk cache, excluding headers. This will be |
| 60 // different from length() if a content encoding was used. |
| 61 virtual int encoded_body_length() const = 0; |
54 }; | 62 }; |
55 | 63 |
56 // A ThreadSafeReceivedData can be deleted on ANY thread. | 64 // A ThreadSafeReceivedData can be deleted on ANY thread. |
57 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; | 65 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; |
58 | 66 |
59 // Called as upload progress is made. | 67 // Called as upload progress is made. |
60 // note: only for requests with upload progress enabled. | 68 // note: only for requests with upload progress enabled. |
61 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; | 69 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; |
62 | 70 |
63 // Called when a redirect occurs. The implementation may return false to | 71 // Called when a redirect occurs. The implementation may return false to |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const std::string& security_info, | 104 const std::string& security_info, |
97 const base::TimeTicks& completion_time, | 105 const base::TimeTicks& completion_time, |
98 int64_t total_transfer_size) = 0; | 106 int64_t total_transfer_size) = 0; |
99 | 107 |
100 virtual ~RequestPeer() {} | 108 virtual ~RequestPeer() {} |
101 }; | 109 }; |
102 | 110 |
103 } // namespace content | 111 } // namespace content |
104 | 112 |
105 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 113 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
OLD | NEW |