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

Side by Side Diff: webkit/fileapi/media_file_util.cc

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 5 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
(Empty)
1 // Copyright (c) 2012 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 "webkit/fileapi/media_file_util.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "webkit/blob/shareable_file_reference.h"
9 #include "webkit/fileapi/file_system_operation_context.h"
10 #include "webkit/fileapi/file_system_url.h"
11 #include "webkit/fileapi/media_device_map_service.h"
12 #include "webkit/fileapi/isolated_context.h"
13
14 #if defined(OS_WIN)
15 #include "webkit/fileapi/mtp_device_interface_win.h"
16 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
17 #include "webkit/fileapi/mtp_device_interface_linux.h"
18 #endif
19
20 using base::PlatformFileError;
21 using base::PlatformFileInfo;
22
23 namespace fileapi {
24
25 namespace {
26
27 bool GetPlatformPathAndDeviceForUrl(
kinuko 2012/07/26 00:38:06 Let's call GetMediaDevice in IsolatedMPP::CreateFi
kmadhusu 2012/07/27 02:13:41 Done.
28 const FileSystemURL& url,
29 FilePath* platform_path,
30 scoped_refptr<MediaDeviceInterfaceImpl>* device) {
31 DCHECK(platform_path);
32 std::string filesystem_id;
33 if (!IsolatedContext::GetInstance()->CrackIsolatedPath(
34 url.path(), &filesystem_id, NULL, platform_path)) {
35 return false;
36 }
37
38 FilePath root_path;
39 if (!IsolatedContext::GetInstance()->GetRegisteredPath(filesystem_id,
40 &root_path)) {
41 return false;
42 }
43
44 if (!MediaDeviceMapService::GetInstance()->GetMediaDevice(root_path.value(),
45 device)) {
46 return false;
47 }
48 return true;
49 }
50
51 } // namespace
52
53
54 MediaFileUtil::MediaFileUtil() {
55 }
56
57 PlatformFileError MediaFileUtil::CreateOrOpen(
58 FileSystemOperationContext* context,
59 const FileSystemURL& url, int file_flags,
60 PlatformFile* file_handle, bool* created) {
61 return base::PLATFORM_FILE_ERROR_SECURITY;
62 }
63
64 PlatformFileError MediaFileUtil::Close(
65 FileSystemOperationContext* context,
66 PlatformFile file_handle) {
67 // We don't allow open thus Close won't be called.
68 return base::PLATFORM_FILE_ERROR_SECURITY;
69 }
70
71 PlatformFileError MediaFileUtil::EnsureFileExists(
72 FileSystemOperationContext* context,
73 const FileSystemURL& url,
74 bool* created) {
75 return base::PLATFORM_FILE_ERROR_SECURITY;
76 }
77
78 PlatformFileError MediaFileUtil::CreateDirectory(
79 FileSystemOperationContext* context,
80 const FileSystemURL& url,
81 bool exclusive,
82 bool recursive) {
83 return base::PLATFORM_FILE_ERROR_SECURITY;
84 }
85
86 PlatformFileError MediaFileUtil::GetFileInfo(
87 FileSystemOperationContext* context,
88 const FileSystemURL& url,
89 PlatformFileInfo* file_info,
90 FilePath* platform_path) {
91 scoped_refptr<MediaDeviceInterfaceImpl> device;
92 if (!GetPlatformPathAndDeviceForUrl(url, platform_path, &device))
93 return base::PLATFORM_FILE_ERROR_INVALID_URL;
94 return device->GetFileInfo(*platform_path, file_info);
95 }
96
97 FileSystemFileUtil::AbstractFileEnumerator*
98 MediaFileUtil::CreateFileEnumerator(
99 FileSystemOperationContext* context,
100 const FileSystemURL& url,
101 bool recursive) {
102 FilePath platform_path;
103 scoped_refptr<MediaDeviceInterfaceImpl> device;
104 if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device))
105 return new FileSystemFileUtil::EmptyFileEnumerator();
106 return device->CreateFileEnumerator(platform_path, recursive);
107 }
108
109 PlatformFileError MediaFileUtil::GetLocalFilePath(
110 FileSystemOperationContext* context,
111 const FileSystemURL& file_system_url,
112 FilePath* local_file_path) {
113 return base::PLATFORM_FILE_ERROR_SECURITY;
114 }
115
116 PlatformFileError MediaFileUtil::Touch(
117 FileSystemOperationContext* context,
118 const FileSystemURL& url,
119 const base::Time& last_access_time,
120 const base::Time& last_modified_time) {
121 FilePath platform_path;
122 scoped_refptr<MediaDeviceInterfaceImpl> device;
123 if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device))
124 return base::PLATFORM_FILE_ERROR_INVALID_URL;
125 return device->Touch(platform_path, last_access_time, last_modified_time);
126 }
127
128 PlatformFileError MediaFileUtil::Truncate(
129 FileSystemOperationContext* context,
130 const FileSystemURL& url,
131 int64 length) {
132 return base::PLATFORM_FILE_ERROR_SECURITY;
133 }
134
135 bool MediaFileUtil::PathExists(
136 FileSystemOperationContext* context,
137 const FileSystemURL& url) {
138 FilePath platform_path;
139 scoped_refptr<MediaDeviceInterfaceImpl> device;
140 if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device))
141 return false;
142 return device->PathExists(platform_path);
143 }
144
145 bool MediaFileUtil::DirectoryExists(
146 FileSystemOperationContext* context,
147 const FileSystemURL& url) {
148 FilePath platform_path;
149 scoped_refptr<MediaDeviceInterfaceImpl> device;
150 if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device))
151 return false;
152 return device->DirectoryExists(platform_path);
153 }
154
155 bool MediaFileUtil::IsDirectoryEmpty(
156 FileSystemOperationContext* context,
157 const FileSystemURL& url) {
158 FilePath platform_path;
159 scoped_refptr<MediaDeviceInterfaceImpl> device;
160 if (!GetPlatformPathAndDeviceForUrl(url, &platform_path, &device))
161 return false;
162 return device->IsDirectoryEmpty(platform_path);
163 }
164
165 PlatformFileError MediaFileUtil::CopyOrMoveFile(
166 FileSystemOperationContext* context,
167 const FileSystemURL& src_url,
168 const FileSystemURL& dest_url,
169 bool copy) {
170 return base::PLATFORM_FILE_ERROR_SECURITY;
171 }
172
173 PlatformFileError MediaFileUtil::CopyInForeignFile(
174 FileSystemOperationContext* context,
175 const FilePath& src_file_path,
176 const FileSystemURL& dest_url) {
177 return base::PLATFORM_FILE_ERROR_SECURITY;
178 }
179
180 PlatformFileError MediaFileUtil::DeleteFile(
181 FileSystemOperationContext* context,
182 const FileSystemURL& url) {
183 return base::PLATFORM_FILE_ERROR_SECURITY;
184 }
185
186 PlatformFileError MediaFileUtil::DeleteSingleDirectory(
187 FileSystemOperationContext* context,
188 const FileSystemURL& url) {
189 return base::PLATFORM_FILE_ERROR_SECURITY;
190 }
191
192 scoped_refptr<webkit_blob::ShareableFileReference>
193 MediaFileUtil::CreateSnapshotFile(
194 FileSystemOperationContext* context,
195 const FileSystemURL& url,
196 base::PlatformFileError* result,
197 base::PlatformFileInfo* file_info,
198 FilePath* platform_path) {
199 return NULL;
200 }
201
202 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698