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 <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/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 bytes_written_(0), | 33 bytes_written_(0), |
34 complete_(false) {} | 34 complete_(false) {} |
35 | 35 |
36 base::PlatformFileError status() const { return status_; } | 36 base::PlatformFileError status() const { return status_; } |
37 void add_bytes_written(int64 bytes, bool complete) { | 37 void add_bytes_written(int64 bytes, bool complete) { |
38 bytes_written_ += bytes; | 38 bytes_written_ += bytes; |
39 EXPECT_FALSE(complete_); | 39 EXPECT_FALSE(complete_); |
40 complete_ = complete; | 40 complete_ = complete; |
41 } | 41 } |
42 int64 bytes_written() const { return bytes_written_; } | 42 int64 bytes_written() const { return bytes_written_; } |
43 bool complete() const { return complete_; } | 43 bool complete() const { return complete_; } |
kinuko
2012/09/25 14:00:49
Can we change this to return WriteCompletionStatus
calvinlo
2012/09/26 05:23:07
Done. Please note that a lot more lines in this fi
| |
44 | 44 |
45 void DidWrite(base::PlatformFileError status, int64 bytes, bool complete) { | 45 void DidWrite(base::PlatformFileError status, int64 bytes, |
46 FileWriterDelegate::WriteCompletionStatus write_status) { | |
46 if (status == base::PLATFORM_FILE_OK) { | 47 if (status == base::PLATFORM_FILE_OK) { |
48 bool complete = (write_status != FileWriterDelegate::NOT_COMPLETE); | |
47 add_bytes_written(bytes, complete); | 49 add_bytes_written(bytes, complete); |
48 if (complete) | 50 if (complete) |
49 MessageLoop::current()->Quit(); | 51 MessageLoop::current()->Quit(); |
50 } else { | 52 } else { |
51 EXPECT_FALSE(complete_); | 53 EXPECT_FALSE(complete_); |
52 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); | 54 EXPECT_EQ(status_, base::PLATFORM_FILE_OK); |
53 complete_ = true; | 55 complete_ = true; |
54 status_ = status; | 56 status_ = status; |
55 MessageLoop::current()->Quit(); | 57 MessageLoop::current()->Quit(); |
56 } | 58 } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 file_writer_delegate_.reset(); | 459 file_writer_delegate_.reset(); |
458 | 460 |
459 EXPECT_EQ(pre_write_usage + allowed_growth, | 461 EXPECT_EQ(pre_write_usage + allowed_growth, |
460 test_helper_.GetCachedOriginUsage()); | 462 test_helper_.GetCachedOriginUsage()); |
461 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage()); | 463 EXPECT_EQ(ComputeCurrentOriginUsage(), test_helper_.GetCachedOriginUsage()); |
462 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written()); | 464 EXPECT_EQ(kOverlap + allowed_growth, result_->bytes_written()); |
463 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); | 465 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, result_->status()); |
464 } | 466 } |
465 | 467 |
466 } // namespace fileapi | 468 } // namespace fileapi |
OLD | NEW |