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

Side by Side Diff: chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.cc

Issue 14615015: Fix name conflict with FileSystemType from winnt.h (Closed) Base URL: svn://svn.chromium.org/chrome
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/media_galleries/fileapi/media_file_system_mount_point_p rovider.h" 5 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p rovider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 17 matching lines...) Expand all
28 #include "webkit/fileapi/isolated_file_util.h" 28 #include "webkit/fileapi/isolated_file_util.h"
29 #include "webkit/fileapi/local_file_stream_writer.h" 29 #include "webkit/fileapi/local_file_stream_writer.h"
30 #include "webkit/fileapi/local_file_system_operation.h" 30 #include "webkit/fileapi/local_file_system_operation.h"
31 #include "webkit/fileapi/native_file_util.h" 31 #include "webkit/fileapi/native_file_util.h"
32 32
33 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 33 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
34 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" 34 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h"
35 #endif 35 #endif
36 36
37 using fileapi::FileSystemContext; 37 using fileapi::FileSystemContext;
38 using fileapi::FileSystemType;
39 using fileapi::FileSystemURL; 38 using fileapi::FileSystemURL;
39 // 'using fileapi::FileSystemType' doesn't work because it conflicts with
40 // winnt.h's FileSystemType enum value in global scope.
40 41
41 namespace chrome { 42 namespace chrome {
42 43
43 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = 44 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] =
44 "MediaPathFilterKey"; 45 "MediaPathFilterKey";
45 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = 46 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] =
46 "MTPDeviceDelegateKey"; 47 "MTPDeviceDelegateKey";
47 48
48 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( 49 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider(
49 const base::FilePath& profile_path) 50 const base::FilePath& profile_path)
50 : profile_path_(profile_path), 51 : profile_path_(profile_path),
51 media_path_filter_(new MediaPathFilter()), 52 media_path_filter_(new MediaPathFilter()),
52 native_media_file_util_( 53 native_media_file_util_(
53 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), 54 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())),
54 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( 55 itunes_file_util_(new fileapi::AsyncFileUtilAdapter(
55 new itunes::ItunesFileUtil())) { 56 new itunes::ItunesFileUtil())) {
56 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 57 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
57 // TODO(kmadhusu): Initialize |device_media_file_util_| in 58 // TODO(kmadhusu): Initialize |device_media_file_util_| in
58 // initialization list. 59 // initialization list.
59 device_media_async_file_util_.reset( 60 device_media_async_file_util_.reset(
60 DeviceMediaAsyncFileUtil::Create(profile_path_)); 61 DeviceMediaAsyncFileUtil::Create(profile_path_));
61 #endif 62 #endif
62 } 63 }
63 64
64 MediaFileSystemMountPointProvider::~MediaFileSystemMountPointProvider() { 65 MediaFileSystemMountPointProvider::~MediaFileSystemMountPointProvider() {
65 } 66 }
66 67
67 bool MediaFileSystemMountPointProvider::CanHandleType( 68 bool MediaFileSystemMountPointProvider::CanHandleType(
68 FileSystemType type) const { 69 fileapi::FileSystemType type) const {
69 switch (type) { 70 switch (type) {
70 case fileapi::kFileSystemTypeNativeMedia: 71 case fileapi::kFileSystemTypeNativeMedia:
71 case fileapi::kFileSystemTypeDeviceMedia: 72 case fileapi::kFileSystemTypeDeviceMedia:
72 case fileapi::kFileSystemTypeItunes: 73 case fileapi::kFileSystemTypeItunes:
73 return true; 74 return true;
74 default: 75 default:
75 return false; 76 return false;
76 } 77 }
77 } 78 }
78 79
79 void MediaFileSystemMountPointProvider::ValidateFileSystemRoot( 80 void MediaFileSystemMountPointProvider::ValidateFileSystemRoot(
80 const GURL& origin_url, 81 const GURL& origin_url,
81 FileSystemType type, 82 fileapi::FileSystemType type,
82 bool create, 83 bool create,
83 const ValidateFileSystemCallback& callback) { 84 const ValidateFileSystemCallback& callback) {
84 // We never allow opening a new isolated FileSystem via usual OpenFileSystem. 85 // We never allow opening a new isolated FileSystem via usual OpenFileSystem.
85 base::MessageLoopProxy::current()->PostTask( 86 base::MessageLoopProxy::current()->PostTask(
86 FROM_HERE, 87 FROM_HERE,
87 base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY)); 88 base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY));
88 } 89 }
89 90
90 base::FilePath 91 base::FilePath
91 MediaFileSystemMountPointProvider::GetFileSystemRootPathOnFileThread( 92 MediaFileSystemMountPointProvider::GetFileSystemRootPathOnFileThread(
92 const FileSystemURL& url, 93 const FileSystemURL& url,
93 bool create) { 94 bool create) {
94 // This is not supposed to be used. 95 // This is not supposed to be used.
95 NOTREACHED(); 96 NOTREACHED();
96 return base::FilePath(); 97 return base::FilePath();
97 } 98 }
98 99
99 fileapi::FileSystemFileUtil* MediaFileSystemMountPointProvider::GetFileUtil( 100 fileapi::FileSystemFileUtil* MediaFileSystemMountPointProvider::GetFileUtil(
100 FileSystemType type) { 101 fileapi::FileSystemType type) {
101 switch (type) { 102 switch (type) {
102 case fileapi::kFileSystemTypeNativeMedia: 103 case fileapi::kFileSystemTypeNativeMedia:
103 return native_media_file_util_->sync_file_util(); 104 return native_media_file_util_->sync_file_util();
104 default: 105 default:
105 NOTREACHED(); 106 NOTREACHED();
106 } 107 }
107 return NULL; 108 return NULL;
108 } 109 }
109 110
110 fileapi::AsyncFileUtil* MediaFileSystemMountPointProvider::GetAsyncFileUtil( 111 fileapi::AsyncFileUtil* MediaFileSystemMountPointProvider::GetAsyncFileUtil(
111 FileSystemType type) { 112 fileapi::FileSystemType type) {
112 switch (type) { 113 switch (type) {
113 case fileapi::kFileSystemTypeNativeMedia: 114 case fileapi::kFileSystemTypeNativeMedia:
114 return native_media_file_util_.get(); 115 return native_media_file_util_.get();
115 case fileapi::kFileSystemTypeDeviceMedia: 116 case fileapi::kFileSystemTypeDeviceMedia:
116 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) 117 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
117 return device_media_async_file_util_.get(); 118 return device_media_async_file_util_.get();
118 #endif 119 #endif
119 case fileapi::kFileSystemTypeItunes: 120 case fileapi::kFileSystemTypeItunes:
120 return itunes_file_util_.get(); 121 return itunes_file_util_.get();
121 default: 122 default:
122 NOTREACHED(); 123 NOTREACHED();
123 } 124 }
124 return NULL; 125 return NULL;
125 } 126 }
126 127
127 fileapi::CopyOrMoveFileValidatorFactory* 128 fileapi::CopyOrMoveFileValidatorFactory*
128 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( 129 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory(
129 FileSystemType type, base::PlatformFileError* error_code) { 130 fileapi::FileSystemType type, base::PlatformFileError* error_code) {
130 DCHECK(error_code); 131 DCHECK(error_code);
131 *error_code = base::PLATFORM_FILE_OK; 132 *error_code = base::PLATFORM_FILE_OK;
132 switch (type) { 133 switch (type) {
133 case fileapi::kFileSystemTypeNativeMedia: 134 case fileapi::kFileSystemTypeNativeMedia:
134 case fileapi::kFileSystemTypeDeviceMedia: 135 case fileapi::kFileSystemTypeDeviceMedia:
135 if (!media_copy_or_move_file_validator_factory_) { 136 if (!media_copy_or_move_file_validator_factory_) {
136 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; 137 *error_code = base::PLATFORM_FILE_ERROR_SECURITY;
137 return NULL; 138 return NULL;
138 } 139 }
139 return media_copy_or_move_file_validator_factory_.get(); 140 return media_copy_or_move_file_validator_factory_.get();
140 default: 141 default:
141 NOTREACHED(); 142 NOTREACHED();
142 } 143 }
143 return NULL; 144 return NULL;
144 } 145 }
145 146
146 void 147 void
147 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( 148 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory(
148 FileSystemType type, 149 fileapi::FileSystemType type,
149 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { 150 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) {
150 switch (type) { 151 switch (type) {
151 case fileapi::kFileSystemTypeNativeMedia: 152 case fileapi::kFileSystemTypeNativeMedia:
152 case fileapi::kFileSystemTypeDeviceMedia: 153 case fileapi::kFileSystemTypeDeviceMedia:
153 if (!media_copy_or_move_file_validator_factory_) 154 if (!media_copy_or_move_file_validator_factory_)
154 media_copy_or_move_file_validator_factory_.reset(factory.release()); 155 media_copy_or_move_file_validator_factory_.reset(factory.release());
155 break; 156 break;
156 default: 157 default:
157 NOTREACHED(); 158 NOTREACHED();
158 } 159 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 211 }
211 212
212 fileapi::FileSystemQuotaUtil* 213 fileapi::FileSystemQuotaUtil*
213 MediaFileSystemMountPointProvider::GetQuotaUtil() { 214 MediaFileSystemMountPointProvider::GetQuotaUtil() {
214 // No quota support. 215 // No quota support.
215 return NULL; 216 return NULL;
216 } 217 }
217 218
218 void MediaFileSystemMountPointProvider::DeleteFileSystem( 219 void MediaFileSystemMountPointProvider::DeleteFileSystem(
219 const GURL& origin_url, 220 const GURL& origin_url,
220 FileSystemType type, 221 fileapi::FileSystemType type,
221 FileSystemContext* context, 222 FileSystemContext* context,
222 const DeleteFileSystemCallback& callback) { 223 const DeleteFileSystemCallback& callback) {
223 NOTREACHED(); 224 NOTREACHED();
224 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 225 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
225 } 226 }
226 227
227 } // namespace chrome 228 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698