| 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 "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_writer_impl.h
" | 5 #include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_writer_impl.h
" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" | 9 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" |
| 10 #include "components/drive/file_system_core_util.h" | 10 #include "components/drive/file_system_core_util.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 callback, base::File::FILE_ERROR_FAILED, base::FilePath(), | 39 callback, base::File::FILE_ERROR_FAILED, base::FilePath(), |
| 40 base::Closure())))); | 40 base::Closure())))); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 WebkitFileStreamWriterImpl::WebkitFileStreamWriterImpl( | 45 WebkitFileStreamWriterImpl::WebkitFileStreamWriterImpl( |
| 46 const FileSystemGetter& file_system_getter, | 46 const FileSystemGetter& file_system_getter, |
| 47 base::TaskRunner* file_task_runner, | 47 base::TaskRunner* file_task_runner, |
| 48 const base::FilePath& file_path, | 48 const base::FilePath& file_path, |
| 49 int64 offset) | 49 int64_t offset) |
| 50 : file_system_getter_(file_system_getter), | 50 : file_system_getter_(file_system_getter), |
| 51 file_task_runner_(file_task_runner), | 51 file_task_runner_(file_task_runner), |
| 52 file_path_(file_path), | 52 file_path_(file_path), |
| 53 offset_(offset), | 53 offset_(offset), |
| 54 weak_ptr_factory_(this) { | 54 weak_ptr_factory_(this) {} |
| 55 } | |
| 56 | 55 |
| 57 WebkitFileStreamWriterImpl::~WebkitFileStreamWriterImpl() { | 56 WebkitFileStreamWriterImpl::~WebkitFileStreamWriterImpl() { |
| 58 if (local_file_writer_) { | 57 if (local_file_writer_) { |
| 59 // If the file is opened, close it at destructor. | 58 // If the file is opened, close it at destructor. |
| 60 // It is necessary to close the local file in advance. | 59 // It is necessary to close the local file in advance. |
| 61 local_file_writer_.reset(); | 60 local_file_writer_.reset(); |
| 62 DCHECK(!close_callback_on_ui_thread_.is_null()); | 61 DCHECK(!close_callback_on_ui_thread_.is_null()); |
| 63 BrowserThread::PostTask(BrowserThread::UI, | 62 BrowserThread::PostTask(BrowserThread::UI, |
| 64 FROM_HERE, | 63 FROM_HERE, |
| 65 close_callback_on_ui_thread_); | 64 close_callback_on_ui_thread_); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 local_path, | 172 local_path, |
| 174 offset_, | 173 offset_, |
| 175 storage::FileStreamWriter::OPEN_EXISTING_FILE)); | 174 storage::FileStreamWriter::OPEN_EXISTING_FILE)); |
| 176 int result = local_file_writer_->Write(buf, buf_len, callback); | 175 int result = local_file_writer_->Write(buf, buf_len, callback); |
| 177 if (result != net::ERR_IO_PENDING) | 176 if (result != net::ERR_IO_PENDING) |
| 178 callback.Run(result); | 177 callback.Run(result); |
| 179 } | 178 } |
| 180 | 179 |
| 181 } // namespace internal | 180 } // namespace internal |
| 182 } // namespace drive | 181 } // namespace drive |
| OLD | NEW |