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 "webkit/browser/fileapi/local_file_stream_writer.h" | 5 #include "webkit/browser/fileapi/local_file_stream_writer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 base::WriteFile(path, data.c_str(), data.size()); | 73 base::WriteFile(path, data.c_str(), data.size()); |
74 return path; | 74 return path; |
75 } | 75 } |
76 | 76 |
77 base::MessageLoopProxy* file_task_runner() const { | 77 base::MessageLoopProxy* file_task_runner() const { |
78 return file_thread_.message_loop_proxy().get(); | 78 return file_thread_.message_loop_proxy().get(); |
79 } | 79 } |
80 | 80 |
81 LocalFileStreamWriter* CreateWriter(const base::FilePath& path, | 81 LocalFileStreamWriter* CreateWriter(const base::FilePath& path, |
82 int64 offset) { | 82 int64 offset) { |
83 return new LocalFileStreamWriter(file_task_runner(), path, offset); | 83 return new LocalFileStreamWriter(file_task_runner(), path, offset, |
| 84 FileStreamWriter::OPEN_EXISTING_FILE); |
84 } | 85 } |
85 | 86 |
86 private: | 87 private: |
87 base::MessageLoopForIO message_loop_; | 88 base::MessageLoopForIO message_loop_; |
88 base::Thread file_thread_; | 89 base::Thread file_thread_; |
89 base::ScopedTempDir temp_dir_; | 90 base::ScopedTempDir temp_dir_; |
90 }; | 91 }; |
91 | 92 |
92 void NeverCalled(int unused) { | 93 void NeverCalled(int unused) { |
93 ADD_FAILURE(); | 94 ADD_FAILURE(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); | 168 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); |
168 ASSERT_EQ(net::ERR_IO_PENDING, result); | 169 ASSERT_EQ(net::ERR_IO_PENDING, result); |
169 | 170 |
170 net::TestCompletionCallback callback; | 171 net::TestCompletionCallback callback; |
171 writer->Cancel(callback.callback()); | 172 writer->Cancel(callback.callback()); |
172 int cancel_result = callback.WaitForResult(); | 173 int cancel_result = callback.WaitForResult(); |
173 EXPECT_EQ(net::OK, cancel_result); | 174 EXPECT_EQ(net::OK, cancel_result); |
174 } | 175 } |
175 | 176 |
176 } // namespace fileapi | 177 } // namespace fileapi |
OLD | NEW |