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

Unified Diff: net/base/upload_bytes_element_reader.cc

Issue 10910268: net: Make UploadDataStream::Read() asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/upload_bytes_element_reader.h ('k') | net/base/upload_bytes_element_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_bytes_element_reader.cc
diff --git a/net/base/upload_bytes_element_reader.cc b/net/base/upload_bytes_element_reader.cc
index 9beb1f436d6573e51383b83fd489e933d3419bd8..22d44f4a9679eeeff60a8f5e854d80551a6ac4e4 100644
--- a/net/base/upload_bytes_element_reader.cc
+++ b/net/base/upload_bytes_element_reader.cc
@@ -5,6 +5,7 @@
#include "net/base/upload_bytes_element_reader.h"
#include "base/logging.h"
+#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
namespace net {
@@ -35,7 +36,18 @@ uint64 UploadBytesElementReader::BytesRemaining() const {
return bytes_length_ - offset_;
}
-int UploadBytesElementReader::ReadSync(char* buf, int buf_length) {
+bool UploadBytesElementReader::IsInMemory() const {
+ return true;
+}
+
+int UploadBytesElementReader::Read(IOBuffer* buf,
+ int buf_length,
+ const CompletionCallback& callback) {
+ DCHECK(!callback.is_null());
+ return ReadSync(buf, buf_length);
+}
+
+int UploadBytesElementReader::ReadSync(IOBuffer* buf, int buf_length) {
DCHECK_LT(0, buf_length);
const size_t num_bytes_to_read =
@@ -45,14 +57,10 @@ int UploadBytesElementReader::ReadSync(char* buf, int buf_length) {
// the address of an element in |bytes_| and that will throw an
// exception if |bytes_| is an empty vector.
if (num_bytes_to_read > 0)
- memcpy(buf, bytes_ + offset_, num_bytes_to_read);
+ memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read);
offset_ += num_bytes_to_read;
return num_bytes_to_read;
}
-bool UploadBytesElementReader::IsInMemory() const {
- return true;
-}
-
} // namespace net
« no previous file with comments | « net/base/upload_bytes_element_reader.h ('k') | net/base/upload_bytes_element_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698