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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 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
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_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>
(...skipping 27 matching lines...) Expand all
38 // destructor) if Init() fails. This method can be called multiple times. 38 // destructor) if Init() fails. This method can be called multiple times.
39 // Calling this method after an Init() success results in resetting the 39 // Calling this method after an Init() success results in resetting the
40 // state (i.e. the stream is rewound). 40 // state (i.e. the stream is rewound).
41 // 41 //
42 // Does the initialization synchronously and returns the result if possible, 42 // Does the initialization synchronously and returns the result if possible,
43 // otherwise returns ERR_IO_PENDING and runs the callback with the result. 43 // otherwise returns ERR_IO_PENDING and runs the callback with the result.
44 // 44 //
45 // Returns OK on success. Returns ERR_UPLOAD_FILE_CHANGED if the expected 45 // Returns OK on success. Returns ERR_UPLOAD_FILE_CHANGED if the expected
46 // file modification time is set (usually not set, but set for sliced 46 // file modification time is set (usually not set, but set for sliced
47 // files) and the target file is changed. 47 // files) and the target file is changed.
48 int Init(const CompletionCallback& callback, const BoundNetLog& net_log); 48 int Init(const CompletionCallback& callback, const NetLogWithSource& net_log);
49 49
50 // When possible, reads up to |buf_len| bytes synchronously from the upload 50 // When possible, reads up to |buf_len| bytes synchronously from the upload
51 // data stream to |buf| and returns the number of bytes read; otherwise, 51 // data stream to |buf| and returns the number of bytes read; otherwise,
52 // returns ERR_IO_PENDING and calls |callback| with the number of bytes read. 52 // returns ERR_IO_PENDING and calls |callback| with the number of bytes read.
53 // Partial reads are allowed. Zero is returned on a call to Read when there 53 // Partial reads are allowed. Zero is returned on a call to Read when there
54 // are no remaining bytes in the stream, and IsEof() will return true 54 // are no remaining bytes in the stream, and IsEof() will return true
55 // hereafter. 55 // hereafter.
56 // 56 //
57 // If there's less data to read than we initially observed (i.e. the actual 57 // If there's less data to read than we initially observed (i.e. the actual
58 // upload data is smaller than size()), zeros are padded to ensure that 58 // upload data is smaller than size()), zeros are padded to ensure that
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void SetSize(uint64_t size); 107 void SetSize(uint64_t size);
108 108
109 // Must be called for chunked uploads before the final ReadInternal call 109 // Must be called for chunked uploads before the final ReadInternal call
110 // completes. Must not be called for non-chunked uploads. 110 // completes. Must not be called for non-chunked uploads.
111 void SetIsFinalChunk(); 111 void SetIsFinalChunk();
112 112
113 private: 113 private:
114 // See Init(). If it returns ERR_IO_PENDING, OnInitCompleted must be called 114 // See Init(). If it returns ERR_IO_PENDING, OnInitCompleted must be called
115 // once it completes. If the upload is not chunked, SetSize must be called 115 // once it completes. If the upload is not chunked, SetSize must be called
116 // before it completes. 116 // before it completes.
117 virtual int InitInternal(const BoundNetLog& net_log) = 0; 117 virtual int InitInternal(const NetLogWithSource& net_log) = 0;
118 118
119 // See Read(). For chunked uploads, must call SetIsFinalChunk if this is the 119 // See Read(). For chunked uploads, must call SetIsFinalChunk if this is the
120 // final chunk. For non-chunked uploads, the UploadDataStream determins which 120 // final chunk. For non-chunked uploads, the UploadDataStream determins which
121 // read is the last based on size. Must read 1 or more bytes on every call, 121 // read is the last based on size. Must read 1 or more bytes on every call,
122 // though the final chunk may be 0 bytes, for chunked requests. If it returns 122 // though the final chunk may be 0 bytes, for chunked requests. If it returns
123 // ERR_IO_PENDING, OnInitCompleted must be called once it completes. Must not 123 // ERR_IO_PENDING, OnInitCompleted must be called once it completes. Must not
124 // return any error, other than ERR_IO_PENDING. 124 // return any error, other than ERR_IO_PENDING.
125 virtual int ReadInternal(IOBuffer* buf, int buf_len) = 0; 125 virtual int ReadInternal(IOBuffer* buf, int buf_len) = 0;
126 126
127 // Resets state and cancels any pending callbacks. Guaranteed to be called 127 // Resets state and cancels any pending callbacks. Guaranteed to be called
128 // before all but the first call to InitInternal. 128 // before all but the first call to InitInternal.
129 virtual void ResetInternal() = 0; 129 virtual void ResetInternal() = 0;
130 130
131 uint64_t total_size_; 131 uint64_t total_size_;
132 uint64_t current_position_; 132 uint64_t current_position_;
133 133
134 const int64_t identifier_; 134 const int64_t identifier_;
135 135
136 const bool is_chunked_; 136 const bool is_chunked_;
137 137
138 // True if the initialization was successful. 138 // True if the initialization was successful.
139 bool initialized_successfully_; 139 bool initialized_successfully_;
140 140
141 bool is_eof_; 141 bool is_eof_;
142 142
143 CompletionCallback callback_; 143 CompletionCallback callback_;
144 144
145 BoundNetLog net_log_; 145 NetLogWithSource net_log_;
146 146
147 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); 147 DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
148 }; 148 };
149 149
150 } // namespace net 150 } // namespace net
151 151
152 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 152 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698