| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "storage/browser/fileapi/local_file_stream_writer.h" | 5 #include "storage/browser/fileapi/local_file_stream_writer.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <string> | 9 #include <string> |
| 8 | 10 |
| 9 #include "base/callback.h" | 11 #include "base/callback.h" |
| 10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/logging.h" | 14 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 base::FilePath path = Path(name); | 77 base::FilePath path = Path(name); |
| 76 base::WriteFile(path, data.c_str(), data.size()); | 78 base::WriteFile(path, data.c_str(), data.size()); |
| 77 return path; | 79 return path; |
| 78 } | 80 } |
| 79 | 81 |
| 80 base::SingleThreadTaskRunner* file_task_runner() const { | 82 base::SingleThreadTaskRunner* file_task_runner() const { |
| 81 return file_thread_.task_runner().get(); | 83 return file_thread_.task_runner().get(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 LocalFileStreamWriter* CreateWriter(const base::FilePath& path, | 86 LocalFileStreamWriter* CreateWriter(const base::FilePath& path, |
| 85 int64 offset) { | 87 int64_t offset) { |
| 86 return new LocalFileStreamWriter(file_task_runner(), path, offset, | 88 return new LocalFileStreamWriter(file_task_runner(), path, offset, |
| 87 FileStreamWriter::OPEN_EXISTING_FILE); | 89 FileStreamWriter::OPEN_EXISTING_FILE); |
| 88 } | 90 } |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 base::MessageLoopForIO message_loop_; | 93 base::MessageLoopForIO message_loop_; |
| 92 base::Thread file_thread_; | 94 base::Thread file_thread_; |
| 93 base::ScopedTempDir temp_dir_; | 95 base::ScopedTempDir temp_dir_; |
| 94 }; | 96 }; |
| 95 | 97 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); | 173 writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled)); |
| 172 ASSERT_EQ(net::ERR_IO_PENDING, result); | 174 ASSERT_EQ(net::ERR_IO_PENDING, result); |
| 173 | 175 |
| 174 net::TestCompletionCallback callback; | 176 net::TestCompletionCallback callback; |
| 175 writer->Cancel(callback.callback()); | 177 writer->Cancel(callback.callback()); |
| 176 int cancel_result = callback.WaitForResult(); | 178 int cancel_result = callback.WaitForResult(); |
| 177 EXPECT_EQ(net::OK, cancel_result); | 179 EXPECT_EQ(net::OK, cancel_result); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace content | 182 } // namespace content |
| OLD | NEW |