provider_async_file_util.cc revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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
3// found in the LICENSE file.
4
5#include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.h"
6
7#include "base/callback.h"
8#include "base/files/file_path.h"
9#include "base/logging.h"
10#include "base/platform_file.h"
11#include "content/public/browser/browser_thread.h"
12#include "webkit/browser/fileapi/file_system_operation_context.h"
13#include "webkit/browser/fileapi/file_system_url.h"
14#include "webkit/common/blob/shareable_file_reference.h"
15
16using content::BrowserThread;
17
18namespace chromeos {
19namespace file_system_provider {
20namespace internal {
21
22ProviderAsyncFileUtil::ProviderAsyncFileUtil() {}
23
24ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {}
25
26void ProviderAsyncFileUtil::CreateOrOpen(
27    scoped_ptr<fileapi::FileSystemOperationContext> context,
28    const fileapi::FileSystemURL& url,
29    int file_flags,
30    const CreateOrOpenCallback& callback) {
31  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
32  base::PlatformFile platform_file = base::kInvalidPlatformFileValue;
33  if ((file_flags & base::PLATFORM_FILE_CREATE) ||
34      (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) ||
35      (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS) ||
36      (file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED)) {
37    callback.Run(base::File::FILE_ERROR_SECURITY,
38                 base::PassPlatformFile(&platform_file),
39                 base::Closure());
40    return;
41  }
42
43  NOTIMPLEMENTED();
44  callback.Run(base::File::FILE_ERROR_NOT_FOUND,
45               base::PassPlatformFile(&platform_file),
46               base::Closure());
47}
48
49void ProviderAsyncFileUtil::EnsureFileExists(
50    scoped_ptr<fileapi::FileSystemOperationContext> context,
51    const fileapi::FileSystemURL& url,
52    const EnsureFileExistsCallback& callback) {
53  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
54  callback.Run(base::File::FILE_ERROR_SECURITY, false /* created */);
55}
56
57void ProviderAsyncFileUtil::CreateDirectory(
58    scoped_ptr<fileapi::FileSystemOperationContext> context,
59    const fileapi::FileSystemURL& url,
60    bool exclusive,
61    bool recursive,
62    const StatusCallback& callback) {
63  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64  callback.Run(base::File::FILE_ERROR_SECURITY);
65}
66
67void ProviderAsyncFileUtil::GetFileInfo(
68    scoped_ptr<fileapi::FileSystemOperationContext> context,
69    const fileapi::FileSystemURL& url,
70    const GetFileInfoCallback& callback) {
71  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72  NOTIMPLEMENTED();
73  callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info());
74}
75
76void ProviderAsyncFileUtil::ReadDirectory(
77    scoped_ptr<fileapi::FileSystemOperationContext> context,
78    const fileapi::FileSystemURL& url,
79    const ReadDirectoryCallback& callback) {
80  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
81  NOTIMPLEMENTED();
82  callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false);
83}
84
85void ProviderAsyncFileUtil::Touch(
86    scoped_ptr<fileapi::FileSystemOperationContext> context,
87    const fileapi::FileSystemURL& url,
88    const base::Time& last_access_time,
89    const base::Time& last_modified_time,
90    const StatusCallback& callback) {
91  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
92  callback.Run(base::File::FILE_ERROR_SECURITY);
93}
94
95void ProviderAsyncFileUtil::Truncate(
96    scoped_ptr<fileapi::FileSystemOperationContext> context,
97    const fileapi::FileSystemURL& url,
98    int64 length,
99    const StatusCallback& callback) {
100  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
101  callback.Run(base::File::FILE_ERROR_SECURITY);
102}
103
104void ProviderAsyncFileUtil::CopyFileLocal(
105    scoped_ptr<fileapi::FileSystemOperationContext> context,
106    const fileapi::FileSystemURL& src_url,
107    const fileapi::FileSystemURL& dest_url,
108    CopyOrMoveOption option,
109    const CopyFileProgressCallback& progress_callback,
110    const StatusCallback& callback) {
111  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
112  callback.Run(base::File::FILE_ERROR_SECURITY);
113}
114
115void ProviderAsyncFileUtil::MoveFileLocal(
116    scoped_ptr<fileapi::FileSystemOperationContext> context,
117    const fileapi::FileSystemURL& src_url,
118    const fileapi::FileSystemURL& dest_url,
119    CopyOrMoveOption option,
120    const StatusCallback& callback) {
121  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
122  callback.Run(base::File::FILE_ERROR_SECURITY);
123}
124
125void ProviderAsyncFileUtil::CopyInForeignFile(
126    scoped_ptr<fileapi::FileSystemOperationContext> context,
127    const base::FilePath& src_file_path,
128    const fileapi::FileSystemURL& dest_url,
129    const StatusCallback& callback) {
130  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
131  callback.Run(base::File::FILE_ERROR_SECURITY);
132}
133
134void ProviderAsyncFileUtil::DeleteFile(
135    scoped_ptr<fileapi::FileSystemOperationContext> context,
136    const fileapi::FileSystemURL& url,
137    const StatusCallback& callback) {
138  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
139  callback.Run(base::File::FILE_ERROR_SECURITY);
140}
141
142void ProviderAsyncFileUtil::DeleteDirectory(
143    scoped_ptr<fileapi::FileSystemOperationContext> context,
144    const fileapi::FileSystemURL& url,
145    const StatusCallback& callback) {
146  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
147  callback.Run(base::File::FILE_ERROR_SECURITY);
148}
149
150void ProviderAsyncFileUtil::DeleteRecursively(
151    scoped_ptr<fileapi::FileSystemOperationContext> context,
152    const fileapi::FileSystemURL& url,
153    const StatusCallback& callback) {
154  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
155  callback.Run(base::File::FILE_ERROR_SECURITY);
156}
157
158void ProviderAsyncFileUtil::CreateSnapshotFile(
159    scoped_ptr<fileapi::FileSystemOperationContext> context,
160    const fileapi::FileSystemURL& url,
161    const CreateSnapshotFileCallback& callback) {
162  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
163  NOTIMPLEMENTED();
164  callback.Run(base::File::FILE_ERROR_NOT_FOUND,
165               base::File::Info(),
166               base::FilePath(),
167               scoped_refptr<webkit_blob::ShareableFileReference>());
168}
169
170}  // namespace internal
171}  // namespace file_system_provider
172}  // namespace chromeos
173