| 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/file_system_provider/provided_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "chrome/browser/chromeos/file_system_provider/operations/close_file.h" | 8 #include "chrome/browser/chromeos/file_system_provider/operations/close_file.h" |
| 9 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" | 9 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
| 10 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h" | 10 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h" |
| 11 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory
.h" | 11 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory
.h" |
| 12 #include "chrome/browser/chromeos/file_system_provider/operations/read_file.h" |
| 12 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h" | 13 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 14 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 14 #include "chrome/common/extensions/api/file_system_provider.h" | 15 #include "chrome/common/extensions/api/file_system_provider.h" |
| 15 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
| 16 | 17 |
| 17 namespace chromeos { | 18 namespace chromeos { |
| 18 namespace file_system_provider { | 19 namespace file_system_provider { |
| 19 namespace { | |
| 20 | |
| 21 } // namespace | |
| 22 | 20 |
| 23 ProvidedFileSystem::ProvidedFileSystem( | 21 ProvidedFileSystem::ProvidedFileSystem( |
| 24 extensions::EventRouter* event_router, | 22 extensions::EventRouter* event_router, |
| 25 const ProvidedFileSystemInfo& file_system_info) | 23 const ProvidedFileSystemInfo& file_system_info) |
| 26 : event_router_(event_router), file_system_info_(file_system_info) { | 24 : event_router_(event_router), file_system_info_(file_system_info) { |
| 27 } | 25 } |
| 28 | 26 |
| 29 ProvidedFileSystem::~ProvidedFileSystem() {} | 27 ProvidedFileSystem::~ProvidedFileSystem() {} |
| 30 | 28 |
| 31 void ProvidedFileSystem::RequestUnmount( | 29 void ProvidedFileSystem::RequestUnmount( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 53 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { | 51 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { |
| 54 if (!request_manager_.CreateRequest(scoped_ptr< | 52 if (!request_manager_.CreateRequest(scoped_ptr< |
| 55 RequestManager::HandlerInterface>(new operations::ReadDirectory( | 53 RequestManager::HandlerInterface>(new operations::ReadDirectory( |
| 56 event_router_, file_system_info_, directory_path, callback)))) { | 54 event_router_, file_system_info_, directory_path, callback)))) { |
| 57 callback.Run(base::File::FILE_ERROR_SECURITY, | 55 callback.Run(base::File::FILE_ERROR_SECURITY, |
| 58 fileapi::AsyncFileUtil::EntryList(), | 56 fileapi::AsyncFileUtil::EntryList(), |
| 59 false /* has_more */); | 57 false /* has_more */); |
| 60 } | 58 } |
| 61 } | 59 } |
| 62 | 60 |
| 61 void ProvidedFileSystem::ReadFile(int file_handle, |
| 62 net::IOBuffer* buffer, |
| 63 int64 offset, |
| 64 int length, |
| 65 const ReadChunkReceivedCallback& callback) { |
| 66 if (!request_manager_.CreateRequest( |
| 67 make_scoped_ptr<RequestManager::HandlerInterface>( |
| 68 new operations::ReadFile(event_router_, |
| 69 file_system_info_, |
| 70 file_handle, |
| 71 buffer, |
| 72 offset, |
| 73 length, |
| 74 callback)))) { |
| 75 callback.Run(0 /* chunk_length */, |
| 76 false /* has_more */, |
| 77 base::File::FILE_ERROR_SECURITY); |
| 78 } |
| 79 } |
| 80 |
| 63 void ProvidedFileSystem::OpenFile(const base::FilePath& file_path, | 81 void ProvidedFileSystem::OpenFile(const base::FilePath& file_path, |
| 64 OpenFileMode mode, | 82 OpenFileMode mode, |
| 65 bool create, | 83 bool create, |
| 66 const OpenFileCallback& callback) { | 84 const OpenFileCallback& callback) { |
| 67 // Writing is not supported. Note, that this includes a situation, when a file | 85 // Writing is not supported. Note, that this includes a situation, when a file |
| 68 // exists, but |create| is set to true. | 86 // exists, but |create| is set to true. |
| 69 if (mode == OPEN_FILE_MODE_WRITE || create) { | 87 if (mode == OPEN_FILE_MODE_WRITE || create) { |
| 70 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); | 88 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); |
| 71 return; | 89 return; |
| 72 } | 90 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { | 115 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { |
| 98 return file_system_info_; | 116 return file_system_info_; |
| 99 } | 117 } |
| 100 | 118 |
| 101 RequestManager* ProvidedFileSystem::GetRequestManager() { | 119 RequestManager* ProvidedFileSystem::GetRequestManager() { |
| 102 return &request_manager_; | 120 return &request_manager_; |
| 103 } | 121 } |
| 104 | 122 |
| 105 } // namespace file_system_provider | 123 } // namespace file_system_provider |
| 106 } // namespace chromeos | 124 } // namespace chromeos |
| OLD | NEW |