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 "content/child/fileapi/webfilewriter_base.h" | 5 #include "content/child/fileapi/webfilewriter_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 bool received_truncate_; | 58 bool received_truncate_; |
59 GURL received_truncate_path_; | 59 GURL received_truncate_path_; |
60 int64 received_truncate_offset_; | 60 int64 received_truncate_offset_; |
61 bool received_write_; | 61 bool received_write_; |
62 GURL received_write_path_; | 62 GURL received_write_path_; |
63 std::string received_write_blob_uuid_; | 63 std::string received_write_blob_uuid_; |
64 int64 received_write_offset_; | 64 int64 received_write_offset_; |
65 bool received_cancel_; | 65 bool received_cancel_; |
66 | 66 |
67 protected: | 67 protected: |
68 virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE { | 68 virtual void DoTruncate(const GURL& path, int64 offset) override { |
69 received_truncate_ = true; | 69 received_truncate_ = true; |
70 received_truncate_path_ = path; | 70 received_truncate_path_ = path; |
71 received_truncate_offset_ = offset; | 71 received_truncate_offset_ = offset; |
72 | 72 |
73 if (offset == kBasicFileTruncate_Offset) { | 73 if (offset == kBasicFileTruncate_Offset) { |
74 DidSucceed(); | 74 DidSucceed(); |
75 } else if (offset == kErrorFileTruncate_Offset) { | 75 } else if (offset == kErrorFileTruncate_Offset) { |
76 DidFail(base::File::FILE_ERROR_NOT_FOUND); | 76 DidFail(base::File::FILE_ERROR_NOT_FOUND); |
77 } else if (offset == kCancelFileTruncate_Offset) { | 77 } else if (offset == kCancelFileTruncate_Offset) { |
78 cancel(); | 78 cancel(); |
79 DidSucceed(); // truncate completion | 79 DidSucceed(); // truncate completion |
80 DidSucceed(); // cancel completion | 80 DidSucceed(); // cancel completion |
81 } else if (offset == kCancelFailedTruncate_Offset) { | 81 } else if (offset == kCancelFailedTruncate_Offset) { |
82 cancel(); | 82 cancel(); |
83 DidFail(base::File::FILE_ERROR_NOT_FOUND); // truncate completion | 83 DidFail(base::File::FILE_ERROR_NOT_FOUND); // truncate completion |
84 DidSucceed(); // cancel completion | 84 DidSucceed(); // cancel completion |
85 } else { | 85 } else { |
86 FAIL(); | 86 FAIL(); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 virtual void DoWrite( | 90 virtual void DoWrite( |
91 const GURL& path, const std::string& blob_uuid, | 91 const GURL& path, const std::string& blob_uuid, |
92 int64 offset) OVERRIDE { | 92 int64 offset) override { |
93 received_write_ = true; | 93 received_write_ = true; |
94 received_write_path_ = path; | 94 received_write_path_ = path; |
95 received_write_offset_ = offset; | 95 received_write_offset_ = offset; |
96 received_write_blob_uuid_ = blob_uuid; | 96 received_write_blob_uuid_ = blob_uuid; |
97 | 97 |
98 if (offset == kBasicFileWrite_Offset) { | 98 if (offset == kBasicFileWrite_Offset) { |
99 DidWrite(1, true); | 99 DidWrite(1, true); |
100 } else if (offset == kErrorFileWrite_Offset) { | 100 } else if (offset == kErrorFileWrite_Offset) { |
101 DidFail(base::File::FILE_ERROR_NOT_FOUND); | 101 DidFail(base::File::FILE_ERROR_NOT_FOUND); |
102 } else if (offset == kMultiFileWrite_Offset) { | 102 } else if (offset == kMultiFileWrite_Offset) { |
(...skipping 12 matching lines...) Expand all Loading... |
115 cancel(); | 115 cancel(); |
116 DidWrite(1, false); | 116 DidWrite(1, false); |
117 DidWrite(1, false); | 117 DidWrite(1, false); |
118 DidWrite(1, true); // write completion | 118 DidWrite(1, true); // write completion |
119 DidFail(base::File::FILE_ERROR_FAILED); // cancel completion | 119 DidFail(base::File::FILE_ERROR_FAILED); // cancel completion |
120 } else { | 120 } else { |
121 FAIL(); | 121 FAIL(); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 virtual void DoCancel() OVERRIDE { | 125 virtual void DoCancel() override { |
126 received_cancel_ = true; | 126 received_cancel_ = true; |
127 } | 127 } |
128 }; | 128 }; |
129 | 129 |
130 class FileWriterTest : public testing::Test, | 130 class FileWriterTest : public testing::Test, |
131 public blink::WebFileWriterClient { | 131 public blink::WebFileWriterClient { |
132 public: | 132 public: |
133 FileWriterTest() { | 133 FileWriterTest() { |
134 reset(); | 134 reset(); |
135 } | 135 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 reset(); | 412 reset(); |
413 delete_in_client_callback_ = true; | 413 delete_in_client_callback_ = true; |
414 writer()->truncate(kErrorFileTruncate_Offset); | 414 writer()->truncate(kErrorFileTruncate_Offset); |
415 EXPECT_FALSE(testable_writer_.get()); | 415 EXPECT_FALSE(testable_writer_.get()); |
416 | 416 |
417 // Not crashing counts as passing. | 417 // Not crashing counts as passing. |
418 } | 418 } |
419 | 419 |
420 } // namespace content | 420 } // namespace content |
OLD | NEW |