OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_BASE_UPLOAD_DATA_STREAM_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ |
6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ | 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/base/upload_progress.h" |
16 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class DrainableIOBuffer; | 21 class DrainableIOBuffer; |
21 class IOBuffer; | 22 class IOBuffer; |
22 class UploadElementReader; | 23 class UploadElementReader; |
23 | 24 |
24 // A class for retrieving all data to be sent as a request body. Supports both | 25 // A class for retrieving all data to be sent as a request body. Supports both |
25 // chunked and non-chunked uploads. | 26 // chunked and non-chunked uploads. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 84 |
84 // Returns true if the upload data in the stream is entirely in memory, and | 85 // Returns true if the upload data in the stream is entirely in memory, and |
85 // all read requests will succeed synchronously. Expected to return false for | 86 // all read requests will succeed synchronously. Expected to return false for |
86 // chunked requests. | 87 // chunked requests. |
87 virtual bool IsInMemory() const; | 88 virtual bool IsInMemory() const; |
88 | 89 |
89 // Returns a list of element readers owned by |this|, if it has any. | 90 // Returns a list of element readers owned by |this|, if it has any. |
90 virtual const std::vector<std::unique_ptr<UploadElementReader>>* | 91 virtual const std::vector<std::unique_ptr<UploadElementReader>>* |
91 GetElementReaders() const; | 92 GetElementReaders() const; |
92 | 93 |
| 94 // Returns the upload progress. If the stream is not initialized |
| 95 // succesfully, it returns empty UploadProgress. |
| 96 virtual UploadProgress GetUploadProgress() const; |
| 97 |
93 protected: | 98 protected: |
94 // Must be called by subclasses when InitInternal and ReadInternal complete | 99 // Must be called by subclasses when InitInternal and ReadInternal complete |
95 // asynchronously. | 100 // asynchronously. |
96 void OnInitCompleted(int result); | 101 void OnInitCompleted(int result); |
97 void OnReadCompleted(int result); | 102 void OnReadCompleted(int result); |
98 | 103 |
99 // Must be called before InitInternal completes, for non-chunked uploads. | 104 // Must be called before InitInternal completes, for non-chunked uploads. |
100 // Must not be called for chunked uploads. | 105 // Must not be called for chunked uploads. |
101 void SetSize(uint64_t size); | 106 void SetSize(uint64_t size); |
102 | 107 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 CompletionCallback callback_; | 142 CompletionCallback callback_; |
138 | 143 |
139 BoundNetLog net_log_; | 144 BoundNetLog net_log_; |
140 | 145 |
141 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 146 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
142 }; | 147 }; |
143 | 148 |
144 } // namespace net | 149 } // namespace net |
145 | 150 |
146 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 151 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |