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

Side by Side Diff: webkit/fileapi/media/device_media_file_util.cc

Issue 10823171: Add path filtering to DeviceMediaFileUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: buildfix for windows Created 8 years, 4 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
« no previous file with comments | « no previous file | webkit/fileapi/media/filtering_file_enumerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "webkit/fileapi/media/device_media_file_util.h" 5 #include "webkit/fileapi/media/device_media_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "webkit/fileapi/file_system_operation_context.h" 10 #include "webkit/fileapi/file_system_operation_context.h"
11 #include "webkit/fileapi/file_system_url.h" 11 #include "webkit/fileapi/file_system_url.h"
12 #include "webkit/fileapi/isolated_context.h" 12 #include "webkit/fileapi/isolated_context.h"
13 #include "webkit/fileapi/media/filtering_file_enumerator.h"
13 #include "webkit/fileapi/media/media_device_interface_impl.h" 14 #include "webkit/fileapi/media/media_device_interface_impl.h"
14 #include "webkit/fileapi/media/media_device_map_service.h" 15 #include "webkit/fileapi/media/media_device_map_service.h"
16 #include "webkit/fileapi/media/media_path_filter.h"
15 17
16 using base::PlatformFileError; 18 using base::PlatformFileError;
17 using base::PlatformFileInfo; 19 using base::PlatformFileInfo;
18 20
19 namespace fileapi { 21 namespace fileapi {
20 22
21 namespace { 23 namespace {
22 24
23 const FilePath::CharType kDeviceMediaFileUtilTempDir[] = 25 const FilePath::CharType kDeviceMediaFileUtilTempDir[] =
24 FILE_PATH_LITERAL("DeviceMediaFileSystem"); 26 FILE_PATH_LITERAL("DeviceMediaFileSystem");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return base::PLATFORM_FILE_ERROR_SECURITY; 60 return base::PLATFORM_FILE_ERROR_SECURITY;
59 } 61 }
60 62
61 PlatformFileError DeviceMediaFileUtil::GetFileInfo( 63 PlatformFileError DeviceMediaFileUtil::GetFileInfo(
62 FileSystemOperationContext* context, 64 FileSystemOperationContext* context,
63 const FileSystemURL& url, 65 const FileSystemURL& url,
64 PlatformFileInfo* file_info, 66 PlatformFileInfo* file_info,
65 FilePath* platform_path) { 67 FilePath* platform_path) {
66 if (!context->media_device()) 68 if (!context->media_device())
67 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 69 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
68 return context->media_device()->GetFileInfo(url.path(), file_info); 70 PlatformFileError error =
71 context->media_device()->GetFileInfo(url.path(), file_info);
72 if (error != base::PLATFORM_FILE_OK)
73 return error;
74
75 if (file_info->is_directory ||
76 context->media_path_filter()->Match(url.path()))
77 return base::PLATFORM_FILE_OK;
78 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
69 } 79 }
70 80
71 FileSystemFileUtil::AbstractFileEnumerator* 81 FileSystemFileUtil::AbstractFileEnumerator*
72 DeviceMediaFileUtil::CreateFileEnumerator( 82 DeviceMediaFileUtil::CreateFileEnumerator(
73 FileSystemOperationContext* context, 83 FileSystemOperationContext* context,
74 const FileSystemURL& url, 84 const FileSystemURL& url,
75 bool recursive) { 85 bool recursive) {
76 if (!context->media_device()) 86 if (!context->media_device())
77 return new FileSystemFileUtil::EmptyFileEnumerator(); 87 return new FileSystemFileUtil::EmptyFileEnumerator();
78 return context->media_device()->CreateFileEnumerator(url.path(), recursive); 88 return new FilteringFileEnumerator(
89 make_scoped_ptr(
90 context->media_device()->CreateFileEnumerator(url.path(), recursive)),
91 context->media_path_filter());
79 } 92 }
80 93
81 PlatformFileError DeviceMediaFileUtil::GetLocalFilePath( 94 PlatformFileError DeviceMediaFileUtil::GetLocalFilePath(
82 FileSystemOperationContext* context, 95 FileSystemOperationContext* context,
83 const FileSystemURL& file_system_url, 96 const FileSystemURL& file_system_url,
84 FilePath* local_file_path) { 97 FilePath* local_file_path) {
85 return base::PLATFORM_FILE_ERROR_SECURITY; 98 return base::PLATFORM_FILE_ERROR_SECURITY;
86 } 99 }
87 100
88 PlatformFileError DeviceMediaFileUtil::Touch( 101 PlatformFileError DeviceMediaFileUtil::Touch(
(...skipping 12 matching lines...) Expand all
101 const FileSystemURL& url, 114 const FileSystemURL& url,
102 int64 length) { 115 int64 length) {
103 return base::PLATFORM_FILE_ERROR_SECURITY; 116 return base::PLATFORM_FILE_ERROR_SECURITY;
104 } 117 }
105 118
106 bool DeviceMediaFileUtil::PathExists( 119 bool DeviceMediaFileUtil::PathExists(
107 FileSystemOperationContext* context, 120 FileSystemOperationContext* context,
108 const FileSystemURL& url) { 121 const FileSystemURL& url) {
109 if (!context->media_device()) 122 if (!context->media_device())
110 return false; 123 return false;
111 return context->media_device()->PathExists(url.path()); 124
125 FilePath path;
126 PlatformFileInfo file_info;
127 PlatformFileError error = GetFileInfo(context, url, &file_info, &path);
128 return error == base::PLATFORM_FILE_OK;
112 } 129 }
113 130
114 bool DeviceMediaFileUtil::DirectoryExists( 131 bool DeviceMediaFileUtil::DirectoryExists(
115 FileSystemOperationContext* context, 132 FileSystemOperationContext* context,
116 const FileSystemURL& url) { 133 const FileSystemURL& url) {
117 if (!context->media_device()) 134 if (!context->media_device())
118 return false; 135 return false;
119 return context->media_device()->DirectoryExists(url.path()); 136 return context->media_device()->DirectoryExists(url.path());
120 } 137 }
121 138
122 bool DeviceMediaFileUtil::IsDirectoryEmpty( 139 bool DeviceMediaFileUtil::IsDirectoryEmpty(
123 FileSystemOperationContext* context, 140 FileSystemOperationContext* context,
124 const FileSystemURL& url) { 141 const FileSystemURL& url) {
125 if (!context->media_device()) 142 if (!context->media_device())
126 return false; 143 return false;
127 return context->media_device()->IsDirectoryEmpty(url.path()); 144
145 scoped_ptr<AbstractFileEnumerator> enumerator(
146 CreateFileEnumerator(context, url, false));
147 FilePath path;
148 while (!(path = enumerator->Next()).empty()) {
149 if (enumerator->IsDirectory() ||
150 context->media_path_filter()->Match(path))
151 return false;
152 }
153 return true;
128 } 154 }
129 155
130 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile( 156 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile(
131 FileSystemOperationContext* context, 157 FileSystemOperationContext* context,
132 const FileSystemURL& src_url, 158 const FileSystemURL& src_url,
133 const FileSystemURL& dest_url, 159 const FileSystemURL& dest_url,
134 bool copy) { 160 bool copy) {
135 return base::PLATFORM_FILE_ERROR_SECURITY; 161 return base::PLATFORM_FILE_ERROR_SECURITY;
136 } 162 }
137 163
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 LOG(WARNING) << "Could not create a temporary file for media snapshot in " 214 LOG(WARNING) << "Could not create a temporary file for media snapshot in "
189 << isolated_media_file_system_dir_path.value(); 215 << isolated_media_file_system_dir_path.value();
190 return base::PLATFORM_FILE_ERROR_FAILED; 216 return base::PLATFORM_FILE_ERROR_FAILED;
191 } 217 }
192 218
193 return context->media_device()->CreateSnapshotFile( 219 return context->media_device()->CreateSnapshotFile(
194 url.path(), *local_path, file_info); 220 url.path(), *local_path, file_info);
195 } 221 }
196 222
197 } // namespace fileapi 223 } // namespace fileapi
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/media/filtering_file_enumerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698