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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc

Issue 258783006: [fsp] Add the getMetadata operation. (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/fileapi/provider_async_fi le_util.h" 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi le_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h"
13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h"
11 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
12 #include "webkit/browser/fileapi/file_system_operation_context.h" 15 #include "webkit/browser/fileapi/file_system_operation_context.h"
13 #include "webkit/browser/fileapi/file_system_url.h" 16 #include "webkit/browser/fileapi/file_system_url.h"
14 #include "webkit/common/blob/shareable_file_reference.h" 17 #include "webkit/common/blob/shareable_file_reference.h"
15 18
16 using content::BrowserThread; 19 using content::BrowserThread;
17 20
18 namespace chromeos { 21 namespace chromeos {
19 namespace file_system_provider { 22 namespace file_system_provider {
20 namespace internal { 23 namespace internal {
24 namespace {
25
26 // Executes GetFileInfo on the UI thread.
27 void GetFileInfoOnUIThread(
28 scoped_ptr<fileapi::FileSystemOperationContext> context,
29 const fileapi::FileSystemURL& url,
30 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) {
31 util::FileSystemURLParser parser(url);
32 if (!parser.Parse()) {
33 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info());
34 return;
35 }
36
37 parser.file_system()->GetMetadata(parser.file_path(), callback);
38 }
39
40 // Routes the response of GetFileInfo back to the IO thread.
41 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback,
42 base::File::Error result,
43 const base::File::Info& file_info) {
44 BrowserThread::PostTask(
45 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info));
46 }
47
48 } // namespace
21 49
22 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} 50 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {}
23 51
24 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} 52 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {}
25 53
26 void ProviderAsyncFileUtil::CreateOrOpen( 54 void ProviderAsyncFileUtil::CreateOrOpen(
27 scoped_ptr<fileapi::FileSystemOperationContext> context, 55 scoped_ptr<fileapi::FileSystemOperationContext> context,
28 const fileapi::FileSystemURL& url, 56 const fileapi::FileSystemURL& url,
29 int file_flags, 57 int file_flags,
30 const CreateOrOpenCallback& callback) { 58 const CreateOrOpenCallback& callback) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const StatusCallback& callback) { 90 const StatusCallback& callback) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64 callback.Run(base::File::FILE_ERROR_SECURITY); 92 callback.Run(base::File::FILE_ERROR_SECURITY);
65 } 93 }
66 94
67 void ProviderAsyncFileUtil::GetFileInfo( 95 void ProviderAsyncFileUtil::GetFileInfo(
68 scoped_ptr<fileapi::FileSystemOperationContext> context, 96 scoped_ptr<fileapi::FileSystemOperationContext> context,
69 const fileapi::FileSystemURL& url, 97 const fileapi::FileSystemURL& url,
70 const GetFileInfoCallback& callback) { 98 const GetFileInfoCallback& callback) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72 NOTIMPLEMENTED(); 100 BrowserThread::PostTask(BrowserThread::UI,
73 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info()); 101 FROM_HERE,
102 base::Bind(&GetFileInfoOnUIThread,
103 base::Passed(&context),
104 url,
105 base::Bind(&OnGetFileInfo, callback)));
74 } 106 }
75 107
76 void ProviderAsyncFileUtil::ReadDirectory( 108 void ProviderAsyncFileUtil::ReadDirectory(
77 scoped_ptr<fileapi::FileSystemOperationContext> context, 109 scoped_ptr<fileapi::FileSystemOperationContext> context,
78 const fileapi::FileSystemURL& url, 110 const fileapi::FileSystemURL& url,
79 const ReadDirectoryCallback& callback) { 111 const ReadDirectoryCallback& callback) {
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
81 NOTIMPLEMENTED(); 113 NOTIMPLEMENTED();
82 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); 114 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false);
83 } 115 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 NOTIMPLEMENTED(); 195 NOTIMPLEMENTED();
164 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 196 callback.Run(base::File::FILE_ERROR_NOT_FOUND,
165 base::File::Info(), 197 base::File::Info(),
166 base::FilePath(), 198 base::FilePath(),
167 scoped_refptr<webkit_blob::ShareableFileReference>()); 199 scoped_refptr<webkit_blob::ShareableFileReference>());
168 } 200 }
169 201
170 } // namespace internal 202 } // namespace internal
171 } // namespace file_system_provider 203 } // namespace file_system_provider
172 } // namespace chromeos 204 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698