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 #include "net/base/upload_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.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" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 OnInitCompleted(result); | 36 OnInitCompleted(result); |
37 } | 37 } |
38 return result; | 38 return result; |
39 } | 39 } |
40 | 40 |
41 int UploadDataStream::Read(IOBuffer* buf, | 41 int UploadDataStream::Read(IOBuffer* buf, |
42 int buf_len, | 42 int buf_len, |
43 const CompletionCallback& callback) { | 43 const CompletionCallback& callback) { |
44 DCHECK(!callback.is_null() || IsInMemory()); | 44 DCHECK(!callback.is_null() || IsInMemory()); |
45 DCHECK(initialized_successfully_); | 45 DCHECK(initialized_successfully_); |
46 DCHECK_GT(buf_len, 0); | 46 DCHECK_GE(buf_len, 0); |
47 if (is_eof_) | 47 if (!buf_len || is_eof_) |
michaeln
2015/03/09 21:15:18
This is a little troublesome because generally rea
mmenke
2015/03/09 21:20:09
Can we instead set is_eof_ to true in SetSize, if
mmenke
2015/03/09 21:22:41
The test should be in elements_upload_data_stream_
cmumford
2015/03/09 22:05:11
Reverted this change as suggested.
| |
48 return 0; | 48 return 0; |
49 int result = ReadInternal(buf, buf_len); | 49 int result = ReadInternal(buf, buf_len); |
50 if (result == ERR_IO_PENDING) { | 50 if (result == ERR_IO_PENDING) { |
51 DCHECK(!IsInMemory()); | 51 DCHECK(!IsInMemory()); |
52 callback_ = callback; | 52 callback_ = callback; |
53 } else { | 53 } else { |
54 OnReadCompleted(result); | 54 OnReadCompleted(result); |
55 } | 55 } |
56 return result; | 56 return result; |
57 } | 57 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 is_eof_ = true; | 119 is_eof_ = true; |
120 } | 120 } |
121 | 121 |
122 DCHECK(result > 0 || is_eof_); | 122 DCHECK(result > 0 || is_eof_); |
123 | 123 |
124 if (!callback_.is_null()) | 124 if (!callback_.is_null()) |
125 base::ResetAndReturn(&callback_).Run(result); | 125 base::ResetAndReturn(&callback_).Run(result); |
126 } | 126 } |
127 | 127 |
128 } // namespace net | 128 } // namespace net |
OLD | NEW |