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

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

Issue 1467603002: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add done_reading_called_ to MockNetworkTransaction 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 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override { 187 int ReadRawData(net::IOBuffer* buf, int buf_size) override {
188 if (remaining_bytes_ < buf_size) 188 if (remaining_bytes_ < buf_size)
189 buf_size = static_cast<int>(remaining_bytes_); 189 buf_size = 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 SetStatus(net::URLRequestStatus()); 195 return buf_size;
196 *bytes_read = buf_size;
197 return true;
198 } 196 }
199 197
200 int GetResponseCode() const override { return 200; } 198 int GetResponseCode() const override { return 200; }
201 199
202 protected: 200 protected:
203 ~FileWriterDelegateTestJob() override {} 201 ~FileWriterDelegateTestJob() override {}
204 202
205 private: 203 private:
206 std::string content_; 204 std::string content_;
207 int remaining_bytes_; 205 int remaining_bytes_;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 file_writer_delegate_.reset(); 487 file_writer_delegate_.reset();
490 488
491 EXPECT_EQ(pre_write_usage + allowed_growth, usage()); 489 EXPECT_EQ(pre_write_usage + allowed_growth, usage());
492 EXPECT_EQ(GetFileSizeOnDisk("test"), usage()); 490 EXPECT_EQ(GetFileSizeOnDisk("test"), usage());
493 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written()); 491 EXPECT_EQ(kOverlap + allowed_growth, result.bytes_written());
494 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status()); 492 EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, result.status());
495 } 493 }
496 } 494 }
497 495
498 } // namespace content 496 } // 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