OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 remaining_bytes_(content.length()), | 177 remaining_bytes_(content.length()), |
178 cursor_(0) { | 178 cursor_(0) { |
179 } | 179 } |
180 | 180 |
181 void Start() override { | 181 void Start() override { |
182 base::ThreadTaskRunnerHandle::Get()->PostTask( | 182 base::ThreadTaskRunnerHandle::Get()->PostTask( |
183 FROM_HERE, | 183 FROM_HERE, |
184 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); | 184 base::Bind(&FileWriterDelegateTestJob::NotifyHeadersComplete, this)); |
185 } | 185 } |
186 | 186 |
187 int ReadRawData(net::IOBuffer* buf, int buf_size) override { | 187 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override { |
188 if (remaining_bytes_ < buf_size) | 188 if (remaining_bytes_ < buf_size) |
189 buf_size = remaining_bytes_; | 189 buf_size = static_cast<int>(remaining_bytes_); |
190 | 190 |
191 for (int i = 0; i < buf_size; ++i) | 191 for (int i = 0; i < buf_size; ++i) |
192 buf->data()[i] = content_[cursor_++]; | 192 buf->data()[i] = content_[cursor_++]; |
193 remaining_bytes_ -= buf_size; | 193 remaining_bytes_ -= buf_size; |
194 | 194 |
195 return buf_size; | 195 SetStatus(net::URLRequestStatus()); |
| 196 *bytes_read = buf_size; |
| 197 return true; |
196 } | 198 } |
197 | 199 |
198 int GetResponseCode() const override { return 200; } | 200 int GetResponseCode() const override { return 200; } |
199 | 201 |
200 protected: | 202 protected: |
201 ~FileWriterDelegateTestJob() override {} | 203 ~FileWriterDelegateTestJob() override {} |
202 | 204 |
203 private: | 205 private: |
204 std::string content_; | 206 std::string content_; |
205 int remaining_bytes_; | 207 int remaining_bytes_; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 file_writer_delegate_.reset(); | 489 file_writer_delegate_.reset(); |
488 | 490 |
489 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); | 491 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); |
490 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); | 492 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); |
491 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); | 493 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); |
492 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); | 494 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); |
493 } | 495 } |
494 } | 496 } |
495 | 497 |
496 } // namespace content | 498 } // namespace content |
OLD | NEW |