Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: net/base/upload_data.h

Issue 10910268: net: Make UploadDataStream::Read() asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments about chunk upload behavior Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
32 protected: 32 protected:
33 virtual ~ChunkCallback() {} 33 virtual ~ChunkCallback() {}
34 }; 34 };
35 35
36 //----------------------------------------------------------------------------- 36 //-----------------------------------------------------------------------------
37 // A very concrete class representing the data to be uploaded as part of a 37 // A very concrete class representing the data to be uploaded as part of a
38 // URLRequest. 38 // URLRequest.
39 // 39 //
40 // Until there is a more abstract class for this, this one derives from 40 // Until there is a more abstract class for this, this one derives from
41 // SupportsUserData to allow users to stash random data by 41 // SupportsUserData to allow users to stash random data by
42 // key and ensure its destruction when UploadData is finally deleted. 42 // key and ensure its destruction when UploadData is finally deleted.
mmenke 2012/10/15 19:54:45 How about a description of how chunked uploading w
hashimoto 2012/10/16 11:52:20 Thank you for this great documentation, though the
43 class NET_EXPORT UploadData 43 class NET_EXPORT UploadData
44 : public base::RefCounted<UploadData>, 44 : public base::RefCounted<UploadData>,
45 public base::SupportsUserData { 45 public base::SupportsUserData {
46 public: 46 public:
47 UploadData(); 47 UploadData();
48 48
49 void AppendBytes(const char* bytes, int bytes_len); 49 void AppendBytes(const char* bytes, int bytes_len);
50 50
51 void AppendFileRange(const FilePath& file_path, 51 void AppendFileRange(const FilePath& file_path,
52 uint64 offset, uint64 length, 52 uint64 offset, uint64 length,
53 const base::Time& expected_modification_time); 53 const base::Time& expected_modification_time);
54 54
55 // Adds the given chunk of bytes to be sent immediately with chunked transfer 55 // Adds the given chunk of bytes to be sent immediately with chunked transfer
56 // encoding. 56 // encoding.
57 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); 57 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk);
58 58
59 // Sets the callback to be invoked when a new chunk is available to upload. 59 // Sets the callback to be invoked when a new chunk is available to upload.
60 void set_chunk_callback(ChunkCallback* callback); 60 void set_chunk_callback(ChunkCallback* callback);
61 61
62 // Initializes the object to send chunks of upload data over time rather 62 // Initializes the object to send chunks of upload data over time rather
63 // than all at once. 63 // than all at once. Only bytes can be appended for chunked data.
mmenke 2012/10/15 19:54:45 Think this statement is too weak, since other func
hashimoto 2012/10/16 11:52:20 Done.
64 void set_is_chunked(bool set) { is_chunked_ = set; } 64 void set_is_chunked(bool set) { is_chunked_ = set; }
65 bool is_chunked() const { return is_chunked_; } 65 bool is_chunked() const { return is_chunked_; }
66 66
67 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } 67 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; }
mmenke 2012/10/15 19:54:45 Maybe a comment that "set_last_chunk_appended() is
hashimoto 2012/10/16 11:52:20 This setter is exposed only for serialization code
68 bool last_chunk_appended() const { return last_chunk_appended_; } 68 bool last_chunk_appended() const { return last_chunk_appended_; }
69 69
70 const std::vector<UploadElement>* elements() const { 70 const std::vector<UploadElement>* elements() const {
71 return &elements_; 71 return &elements_;
72 } 72 }
73 73
74 std::vector<UploadElement>* elements_mutable() { 74 std::vector<UploadElement>* elements_mutable() {
75 return &elements_; 75 return &elements_;
76 } 76 }
77 77
(...skipping 19 matching lines...) Expand all
97 ChunkCallback* chunk_callback_; 97 ChunkCallback* chunk_callback_;
98 bool is_chunked_; 98 bool is_chunked_;
99 bool last_chunk_appended_; 99 bool last_chunk_appended_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(UploadData); 101 DISALLOW_COPY_AND_ASSIGN(UploadData);
102 }; 102 };
103 103
104 } // namespace net 104 } // namespace net
105 105
106 #endif // NET_BASE_UPLOAD_DATA_H_ 106 #endif // NET_BASE_UPLOAD_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698