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

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

Issue 279213002: [fsp] Add support for closing 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/close_file.h"
8 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h " 9 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h "
9 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h" 10 #include "chrome/browser/chromeos/file_system_provider/operations/open_file.h"
10 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory .h" 11 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory .h"
11 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h" 12 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.h"
12 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" 13 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
13 #include "chrome/common/extensions/api/file_system_provider.h" 14 #include "chrome/common/extensions/api/file_system_provider.h"
14 #include "extensions/browser/event_router.h" 15 #include "extensions/browser/event_router.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 namespace file_system_provider { 18 namespace file_system_provider {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { 53 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) {
53 if (!request_manager_.CreateRequest(scoped_ptr< 54 if (!request_manager_.CreateRequest(scoped_ptr<
54 RequestManager::HandlerInterface>(new operations::ReadDirectory( 55 RequestManager::HandlerInterface>(new operations::ReadDirectory(
55 event_router_, file_system_info_, directory_path, callback)))) { 56 event_router_, file_system_info_, directory_path, callback)))) {
56 callback.Run(base::File::FILE_ERROR_SECURITY, 57 callback.Run(base::File::FILE_ERROR_SECURITY,
57 fileapi::AsyncFileUtil::EntryList(), 58 fileapi::AsyncFileUtil::EntryList(),
58 false /* has_more */); 59 false /* has_more */);
59 } 60 }
60 } 61 }
61 62
62 void ProvidedFileSystem::OpenFile( 63 void ProvidedFileSystem::OpenFile(const base::FilePath& file_path,
63 const base::FilePath& file_path, 64 OpenFileMode mode,
64 OpenFileMode mode, 65 bool create,
65 bool create, 66 const OpenFileCallback& callback) {
66 const fileapi::AsyncFileUtil::StatusCallback& callback) {
67 // Writing is not supported. Note, that this includes a situation, when a file 67 // Writing is not supported. Note, that this includes a situation, when a file
68 // exists, but |create| is set to true. 68 // exists, but |create| is set to true.
69 if (mode == OPEN_FILE_MODE_WRITE || create) { 69 if (mode == OPEN_FILE_MODE_WRITE || create) {
70 callback.Run(base::File::FILE_ERROR_SECURITY); 70 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY);
71 return; 71 return;
72 } 72 }
73 73
74 if (!request_manager_.CreateRequest( 74 if (!request_manager_.CreateRequest(
75 scoped_ptr<RequestManager::HandlerInterface>( 75 scoped_ptr<RequestManager::HandlerInterface>(
76 new operations::OpenFile(event_router_, 76 new operations::OpenFile(event_router_,
77 file_system_info_, 77 file_system_info_,
78 file_path, 78 file_path,
79 mode, 79 mode,
80 create, 80 create,
81 callback)))) { 81 callback)))) {
82 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY);
83 }
84 }
85
86 void ProvidedFileSystem::CloseFile(
87 int file_handle,
88 const fileapi::AsyncFileUtil::StatusCallback& callback) {
89 if (!request_manager_.CreateRequest(
90 scoped_ptr<RequestManager::HandlerInterface>(
91 new operations::CloseFile(
92 event_router_, file_system_info_, file_handle, callback)))) {
82 callback.Run(base::File::FILE_ERROR_SECURITY); 93 callback.Run(base::File::FILE_ERROR_SECURITY);
83 } 94 }
84 } 95 }
85 96
86 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { 97 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const {
87 return file_system_info_; 98 return file_system_info_;
88 } 99 }
89 100
90 RequestManager* ProvidedFileSystem::GetRequestManager() { 101 RequestManager* ProvidedFileSystem::GetRequestManager() {
91 return &request_manager_; 102 return &request_manager_;
92 } 103 }
93 104
94 } // namespace file_system_provider 105 } // namespace file_system_provider
95 } // namespace chromeos 106 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698