Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/chromeos/file_system_provider/provided_file_system.cc

Issue 284443002: [fsp] Add support for opening files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/get_metadata.h " 8 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h "
9 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h"
9 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory .h" 10 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory .h"
10 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h" 11 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h"
11 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" 12 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
12 #include "chrome/common/extensions/api/file_system_provider.h" 13 #include "chrome/common/extensions/api/file_system_provider.h"
13 #include "extensions/browser/event_router.h" 14 #include "extensions/browser/event_router.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 namespace file_system_provider { 17 namespace file_system_provider {
17 namespace { 18 namespace {
18 19
19 } // namespace 20 } // namespace
20 21
21 ProvidedFileSystem::ProvidedFileSystem( 22 ProvidedFileSystem::ProvidedFileSystem(
22 extensions::EventRouter* event_router, 23 extensions::EventRouter* event_router,
23 const ProvidedFileSystemInfo& file_system_info) 24 const ProvidedFileSystemInfo& file_system_info)
24 : event_router_(event_router), file_system_info_(file_system_info) { 25 : event_router_(event_router), file_system_info_(file_system_info) {
25 } 26 }
26 27
27 ProvidedFileSystem::~ProvidedFileSystem() {} 28 ProvidedFileSystem::~ProvidedFileSystem() {}
28 29
29 void ProvidedFileSystem::RequestUnmount( 30 void ProvidedFileSystem::RequestUnmount(
30 const fileapi::AsyncFileUtil::StatusCallback& callback) { 31 const fileapi::AsyncFileUtil::StatusCallback& callback) {
31 if (!request_manager_.CreateRequest( 32 if (!request_manager_.CreateRequest(
32 make_scoped_ptr<RequestManager::HandlerInterface>( 33 scoped_ptr<RequestManager::HandlerInterface>(new operations::Unmount(
33 new operations::Unmount( 34 event_router_, file_system_info_, callback)))) {
34 event_router_, file_system_info_, callback)))) {
35 callback.Run(base::File::FILE_ERROR_SECURITY); 35 callback.Run(base::File::FILE_ERROR_SECURITY);
36 } 36 }
37 } 37 }
38 38
39 void ProvidedFileSystem::GetMetadata( 39 void ProvidedFileSystem::GetMetadata(
40 const base::FilePath& entry_path, 40 const base::FilePath& entry_path,
41 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) { 41 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) {
42 if (!request_manager_.CreateRequest( 42 if (!request_manager_.CreateRequest(
43 make_scoped_ptr<RequestManager::HandlerInterface>( 43 scoped_ptr<RequestManager::HandlerInterface>(
44 new operations::GetMetadata( 44 new operations::GetMetadata(
45 event_router_, file_system_info_, entry_path, callback)))) { 45 event_router_, file_system_info_, entry_path, callback)))) {
46 callback.Run(base::File::FILE_ERROR_SECURITY, base::File::Info()); 46 callback.Run(base::File::FILE_ERROR_SECURITY, base::File::Info());
47 } 47 }
48 } 48 }
49 49
50 void ProvidedFileSystem::ReadDirectory( 50 void ProvidedFileSystem::ReadDirectory(
51 const base::FilePath& directory_path, 51 const base::FilePath& directory_path,
52 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { 52 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) {
53 if (!request_manager_.CreateRequest(make_scoped_ptr< 53 if (!request_manager_.CreateRequest(scoped_ptr<
54 RequestManager::HandlerInterface>(new operations::ReadDirectory( 54 RequestManager::HandlerInterface>(new operations::ReadDirectory(
55 event_router_, file_system_info_, directory_path, callback)))) { 55 event_router_, file_system_info_, directory_path, callback)))) {
56 callback.Run(base::File::FILE_ERROR_SECURITY, 56 callback.Run(base::File::FILE_ERROR_SECURITY,
57 fileapi::AsyncFileUtil::EntryList(), 57 fileapi::AsyncFileUtil::EntryList(),
58 false /* has_more */); 58 false /* has_more */);
59 } 59 }
60 } 60 }
61 61
62 void ProvidedFileSystem::OpenFile(
63 const base::FilePath& file_path,
64 OpenFileMode mode,
65 bool create,
66 const fileapi::AsyncFileUtil::StatusCallback& callback) {
67 // Writing is not supported. Note, that this includes a situation, when a file
68 // exists, but |create| is set to true.
69 if (mode == OPEN_FILE_MODE_WRITE || create) {
70 callback.Run(base::File::FILE_ERROR_SECURITY);
71 return;
72 }
73
74 if (!request_manager_.CreateRequest(
75 scoped_ptr<RequestManager::HandlerInterface>(
76 new operations::OpenFile(event_router_,
77 file_system_info_,
78 file_path,
79 mode,
80 create,
81 callback)))) {
82 callback.Run(base::File::FILE_ERROR_SECURITY);
83 }
84 }
85
62 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { 86 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
63 return file_system_info_; 87 return file_system_info_;
64 } 88 }
65 89
66 RequestManager* ProvidedFileSystem::GetRequestManager() { 90 RequestManager* ProvidedFileSystem::GetRequestManager() {
67 return &request_manager_; 91 return &request_manager_;
68 } 92 }
69 93
70 } // namespace file_system_provider 94 } // namespace file_system_provider
71 } // namespace chromeos 95 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698