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 |
46 // are thread-safe, but the data object itself must be destroyed on the | |
47 // original thread. | |
kinuko
2016/07/04 04:08:12
nit: weird line wrapping
Adam Rice
2016/07/04 06:33:42
Fixed.
| |
45 class CONTENT_EXPORT ReceivedData { | 48 class CONTENT_EXPORT ReceivedData { |
46 public: | 49 public: |
47 virtual ~ReceivedData() {} | 50 virtual ~ReceivedData() {} |
48 virtual const char* payload() const = 0; | 51 virtual const char* payload() const = 0; |
49 virtual int length() const = 0; | 52 virtual int length() const = 0; |
50 // The encoded_length is the length of the encoded data transferred | 53 // 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 | 54 // over the network, including headers. It is only set for responses |
52 // gzipped content). | 55 // originating from the network (ie. not the cache). It will usually be |
53 virtual int encoded_length() const = 0; | 56 // different from length(), and may be smaller if the content was |
57 // compressed. | |
58 virtual int encoded_data_length() const = 0; | |
kinuko
2016/07/04 04:08:12
We often seem to set this to -1 in tests and also
Adam Rice
2016/07/04 06:33:42
I have added a comment that "-1 means this value i
| |
59 // The encoded_body_length is the size of the body as transferred over the | |
60 // network or stored in the disk cache. This will be different from the data | |
kinuko
2016/07/04 04:08:12
'excluding headers' ...?
Adam Rice
2016/07/04 06:33:42
Added.
| |
61 // length if a content encoding was used. | |
62 virtual int encoded_body_length() const = 0; | |
54 }; | 63 }; |
55 | 64 |
56 // A ThreadSafeReceivedData can be deleted on ANY thread. | 65 // A ThreadSafeReceivedData can be deleted on ANY thread. |
57 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; | 66 class CONTENT_EXPORT ThreadSafeReceivedData : public ReceivedData {}; |
58 | 67 |
59 // Called as upload progress is made. | 68 // Called as upload progress is made. |
60 // note: only for requests with upload progress enabled. | 69 // note: only for requests with upload progress enabled. |
61 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; | 70 virtual void OnUploadProgress(uint64_t position, uint64_t size) = 0; |
62 | 71 |
63 // Called when a redirect occurs. The implementation may return false to | 72 // 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, | 105 const std::string& security_info, |
97 const base::TimeTicks& completion_time, | 106 const base::TimeTicks& completion_time, |
98 int64_t total_transfer_size) = 0; | 107 int64_t total_transfer_size) = 0; |
99 | 108 |
100 virtual ~RequestPeer() {} | 109 virtual ~RequestPeer() {} |
101 }; | 110 }; |
102 | 111 |
103 } // namespace content | 112 } // namespace content |
104 | 113 |
105 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ | 114 #endif // CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
OLD | NEW |