| 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 was not initialized |
| 95 // successfully, or has been reset and not yet re-initialized, returns an |
| 96 // empty UploadProgress. |
| 97 virtual UploadProgress GetUploadProgress() const; |
| 98 |
| 93 protected: | 99 protected: |
| 94 // Must be called by subclasses when InitInternal and ReadInternal complete | 100 // Must be called by subclasses when InitInternal and ReadInternal complete |
| 95 // asynchronously. | 101 // asynchronously. |
| 96 void OnInitCompleted(int result); | 102 void OnInitCompleted(int result); |
| 97 void OnReadCompleted(int result); | 103 void OnReadCompleted(int result); |
| 98 | 104 |
| 99 // Must be called before InitInternal completes, for non-chunked uploads. | 105 // Must be called before InitInternal completes, for non-chunked uploads. |
| 100 // Must not be called for chunked uploads. | 106 // Must not be called for chunked uploads. |
| 101 void SetSize(uint64_t size); | 107 void SetSize(uint64_t size); |
| 102 | 108 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 CompletionCallback callback_; | 143 CompletionCallback callback_; |
| 138 | 144 |
| 139 BoundNetLog net_log_; | 145 BoundNetLog net_log_; |
| 140 | 146 |
| 141 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 147 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
| 142 }; | 148 }; |
| 143 | 149 |
| 144 } // namespace net | 150 } // namespace net |
| 145 | 151 |
| 146 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 152 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
| OLD | NEW |