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

Side by Side Diff: content/browser/fileapi/file_writer_delegate_unittest.cc

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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
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
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
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job.cc ('k') | content/browser/net/view_http_cache_job_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698