| 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_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_H_ |
| 6 #define NET_BASE_UPLOAD_DATA_H_ | 6 #define NET_BASE_UPLOAD_DATA_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); | 58 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); |
| 59 | 59 |
| 60 // Sets the callback to be invoked when a new chunk is available to upload. | 60 // Sets the callback to be invoked when a new chunk is available to upload. |
| 61 void set_chunk_callback(ChunkCallback* callback); | 61 void set_chunk_callback(ChunkCallback* callback); |
| 62 | 62 |
| 63 // Initializes the object to send chunks of upload data over time rather | 63 // Initializes the object to send chunks of upload data over time rather |
| 64 // than all at once. | 64 // than all at once. |
| 65 void set_is_chunked(bool set) { is_chunked_ = set; } | 65 void set_is_chunked(bool set) { is_chunked_ = set; } |
| 66 bool is_chunked() const { return is_chunked_; } | 66 bool is_chunked() const { return is_chunked_; } |
| 67 | 67 |
| 68 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } |
| 69 bool last_chunk_appended() const { return last_chunk_appended_; } |
| 70 |
| 68 // Gets the total size in bytes of the data to upload. Computing the | 71 // Gets the total size in bytes of the data to upload. Computing the |
| 69 // content length can result in performing file IO hence the operation is | 72 // content length can result in performing file IO hence the operation is |
| 70 // done asynchronously. Runs the callback with the content length once the | 73 // done asynchronously. Runs the callback with the content length once the |
| 71 // computation is done. | 74 // computation is done. |
| 72 typedef base::Callback<void(uint64 content_length)> ContentLengthCallback; | 75 typedef base::Callback<void(uint64 content_length)> ContentLengthCallback; |
| 73 void GetContentLength(const ContentLengthCallback& callback); | 76 void GetContentLength(const ContentLengthCallback& callback); |
| 74 | 77 |
| 75 // Returns the total size in bytes of the data to upload, for testing. | 78 // Returns the total size in bytes of the data to upload, for testing. |
| 76 // This version may perform file IO on the current thread. This function | 79 // This version may perform file IO on the current thread. This function |
| 77 // will fail if called on a thread where file IO is prohibited. Usually | 80 // will fail if called on a thread where file IO is prohibited. Usually |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 void DoGetContentLength(uint64* content_length); | 115 void DoGetContentLength(uint64* content_length); |
| 113 | 116 |
| 114 friend class base::RefCounted<UploadData>; | 117 friend class base::RefCounted<UploadData>; |
| 115 | 118 |
| 116 virtual ~UploadData(); | 119 virtual ~UploadData(); |
| 117 | 120 |
| 118 std::vector<UploadElement> elements_; | 121 std::vector<UploadElement> elements_; |
| 119 int64 identifier_; | 122 int64 identifier_; |
| 120 ChunkCallback* chunk_callback_; | 123 ChunkCallback* chunk_callback_; |
| 121 bool is_chunked_; | 124 bool is_chunked_; |
| 125 bool last_chunk_appended_; |
| 122 | 126 |
| 123 DISALLOW_COPY_AND_ASSIGN(UploadData); | 127 DISALLOW_COPY_AND_ASSIGN(UploadData); |
| 124 }; | 128 }; |
| 125 | 129 |
| 126 } // namespace net | 130 } // namespace net |
| 127 | 131 |
| 128 #endif // NET_BASE_UPLOAD_DATA_H_ | 132 #endif // NET_BASE_UPLOAD_DATA_H_ |
| OLD | NEW |