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); | |
85 } | 84 } |
86 | 85 |
87 private: | 86 private: |
88 base::MessageLoopForIO message_loop_; | 87 base::MessageLoopForIO message_loop_; |
89 base::Thread file_thread_; | 88 base::Thread file_thread_; |
90 base::ScopedTempDir temp_dir_; | 89 base::ScopedTempDir temp_dir_; |
91 }; | 90 }; |
92 | 91 |
93 void NeverCalled(int unused) { | 92 void NeverCalled(int unused) { |
94 ADD_FAILURE(); | 93 ADD_FAILURE(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); | 167 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); |
169 ASSERT_EQ(net::ERR_IO_PENDING, result); | 168 ASSERT_EQ(net::ERR_IO_PENDING, result); |
170 | 169 |
171 net::TestCompletionCallback callback; | 170 net::TestCompletionCallback callback; |
172 writer->Cancel(callback.callback()); | 171 writer->Cancel(callback.callback()); |
173 int cancel_result = callback.WaitForResult(); | 172 int cancel_result = callback.WaitForResult(); |
174 EXPECT_EQ(net::OK, cancel_result); | 173 EXPECT_EQ(net::OK, cancel_result); |
175 } | 174 } |
176 | 175 |
177 } // namespace fileapi | 176 } // namespace fileapi |
OLD | NEW |