| 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/fileapi/file_system_file_stream_reader.h" | 5 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 6 | 6 |
| 7 #include "base/file_util_proxy.h" | 7 #include "base/file_util_proxy.h" |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 FileSystemFileStreamReader::~FileSystemFileStreamReader() { | 47 FileSystemFileStreamReader::~FileSystemFileStreamReader() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 int FileSystemFileStreamReader::Read( | 50 int FileSystemFileStreamReader::Read( |
| 51 net::IOBuffer* buf, int buf_len, | 51 net::IOBuffer* buf, int buf_len, |
| 52 const net::CompletionCallback& callback) { | 52 const net::CompletionCallback& callback) { |
| 53 if (local_file_reader_.get()) | 53 if (local_file_reader_.get()) |
| 54 return local_file_reader_->Read(buf, buf_len, callback); | 54 return local_file_reader_->Read(buf, buf_len, callback); |
| 55 DCHECK(!has_pending_create_snapshot_); | 55 DCHECK(!has_pending_create_snapshot_); |
| 56 base::PlatformFileError error_code; |
| 56 FileSystemOperation* operation = | 57 FileSystemOperation* operation = |
| 57 file_system_context_->CreateFileSystemOperation(url_); | 58 file_system_context_->CreateFileSystemOperation(url_, &error_code); |
| 58 if (!operation) | 59 if (error_code != base::PLATFORM_FILE_OK) |
| 59 return net::ERR_INVALID_URL; | 60 return net::PlatformFileErrorToNetError(error_code); |
| 60 has_pending_create_snapshot_ = true; | 61 has_pending_create_snapshot_ = true; |
| 61 operation->CreateSnapshotFile( | 62 operation->CreateSnapshotFile( |
| 62 url_, | 63 url_, |
| 63 base::Bind(&FileSystemFileStreamReader::DidCreateSnapshot, | 64 base::Bind(&FileSystemFileStreamReader::DidCreateSnapshot, |
| 64 weak_factory_.GetWeakPtr(), | 65 weak_factory_.GetWeakPtr(), |
| 65 base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(), | 66 base::Bind(&ReadAdapter, weak_factory_.GetWeakPtr(), |
| 66 make_scoped_refptr(buf), buf_len, callback), | 67 make_scoped_refptr(buf), buf_len, callback), |
| 67 callback)); | 68 callback)); |
| 68 return net::ERR_IO_PENDING; | 69 return net::ERR_IO_PENDING; |
| 69 } | 70 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 | 90 |
| 90 local_file_reader_.reset( | 91 local_file_reader_.reset( |
| 91 new LocalFileStreamReader( | 92 new LocalFileStreamReader( |
| 92 file_system_context_->task_runners()->file_task_runner(), | 93 file_system_context_->task_runners()->file_task_runner(), |
| 93 platform_path, initial_offset_, base::Time())); | 94 platform_path, initial_offset_, base::Time())); |
| 94 | 95 |
| 95 read_closure.Run(); | 96 read_closure.Run(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace fileapi | 99 } // namespace fileapi |
| OLD | NEW |