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

Side by Side Diff: components/cronet/android/wrapped_channel_upload_element_reader.cc

Issue 640593004: Fix a pair of Cronet upload bugs and add tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder fields Created 6 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
« no previous file with comments | « components/cronet/android/test/upload_test_server.cc ('k') | net/base/net_error_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" 5 #include "components/cronet/android/wrapped_channel_upload_element_reader.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 11
12 namespace cronet { 12 namespace cronet {
13 13
14 WrappedChannelElementReader::WrappedChannelElementReader( 14 WrappedChannelElementReader::WrappedChannelElementReader(
15 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate, 15 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate,
16 uint64 length) 16 uint64 length)
17 : length_(length), offset_(0), delegate_(delegate) { 17 : length_(length), offset_(0), delegate_(delegate) {
18 } 18 }
19 19
20 WrappedChannelElementReader::~WrappedChannelElementReader() { 20 WrappedChannelElementReader::~WrappedChannelElementReader() {
21 } 21 }
22 22
23 int WrappedChannelElementReader::Init(const net::CompletionCallback& callback) { 23 int WrappedChannelElementReader::Init(const net::CompletionCallback& callback) {
24 offset_ = 0; 24 if (offset_ != 0)
25 return net::ERR_UPLOAD_STREAM_REWIND_NOT_SUPPORTED;
25 return net::OK; 26 return net::OK;
26 } 27 }
27 28
28 uint64 WrappedChannelElementReader::GetContentLength() const { 29 uint64 WrappedChannelElementReader::GetContentLength() const {
29 return length_; 30 return length_;
30 } 31 }
31 32
32 uint64 WrappedChannelElementReader::BytesRemaining() const { 33 uint64 WrappedChannelElementReader::BytesRemaining() const {
33 return length_ - offset_; 34 return length_ - offset_;
34 } 35 }
(...skipping 10 matching lines...) Expand all
45 // TODO(mef): Post the read to file thread. 46 // TODO(mef): Post the read to file thread.
46 int bytes_read = delegate_->ReadFromUploadChannel(buf, buf_length); 47 int bytes_read = delegate_->ReadFromUploadChannel(buf, buf_length);
47 if (bytes_read < 0) 48 if (bytes_read < 0)
48 return net::ERR_FAILED; 49 return net::ERR_FAILED;
49 offset_ += bytes_read; 50 offset_ += bytes_read;
50 return bytes_read; 51 return bytes_read;
51 } 52 }
52 53
53 } // namespace cronet 54 } // namespace cronet
54 55
OLDNEW
« no previous file with comments | « components/cronet/android/test/upload_test_server.cc ('k') | net/base/net_error_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698