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

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

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
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/isolated_mount_point_provider.h" 5 #include "webkit/fileapi/isolated_mount_point_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "webkit/blob/local_file_stream_reader.h" 14 #include "webkit/blob/local_file_stream_reader.h"
15 #include "webkit/fileapi/file_system_callback_dispatcher.h" 15 #include "webkit/fileapi/file_system_callback_dispatcher.h"
16 #include "webkit/fileapi/file_system_context.h" 16 #include "webkit/fileapi/file_system_context.h"
17 #include "webkit/fileapi/file_system_file_stream_reader.h" 17 #include "webkit/fileapi/file_system_file_stream_reader.h"
18 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/fileapi/file_system_util.h" 19 #include "webkit/fileapi/file_system_util.h"
20 #include "webkit/fileapi/isolated_context.h" 20 #include "webkit/fileapi/isolated_context.h"
21 #include "webkit/fileapi/isolated_file_util.h" 21 #include "webkit/fileapi/isolated_file_util.h"
22 #include "webkit/fileapi/media_device_map_service.h"
23 #include "webkit/fileapi/media_file_util.h"
22 #include "webkit/fileapi/local_file_stream_writer.h" 24 #include "webkit/fileapi/local_file_stream_writer.h"
23 #include "webkit/fileapi/local_file_system_operation.h" 25 #include "webkit/fileapi/local_file_system_operation.h"
24 #include "webkit/fileapi/native_file_util.h" 26 #include "webkit/fileapi/native_file_util.h"
25 27
26 namespace fileapi { 28 namespace fileapi {
27 29
28 namespace { 30 namespace {
29 31
30 IsolatedContext* isolated_context() { 32 IsolatedContext* isolated_context() {
31 return IsolatedContext::GetInstance(); 33 return IsolatedContext::GetInstance();
32 } 34 }
33 35
34 FilePath GetPathFromURL(const FileSystemURL& url) { 36 FilePath GetPathFromURL(const FileSystemURL& url) {
35 if (!url.is_valid() || url.type() != kFileSystemTypeIsolated) 37 if (!url.is_valid() || url.type() != kFileSystemTypeIsolated)
36 return FilePath(); 38 return FilePath();
37 std::string fsid; 39 std::string fsid;
38 FilePath path; 40 FilePath path;
39 if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path)) 41 if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path))
40 return FilePath(); 42 return FilePath();
41 return path; 43 return path;
42 } 44 }
43 45
44 } // namespace 46 } // namespace
45 47
46 IsolatedMountPointProvider::IsolatedMountPointProvider() 48 IsolatedMountPointProvider::IsolatedMountPointProvider()
47 : isolated_file_util_(new IsolatedFileUtil()) { 49 : isolated_file_util_(new IsolatedFileUtil()),
50 media_file_util_(new MediaFileUtil()) {
48 } 51 }
49 52
50 IsolatedMountPointProvider::~IsolatedMountPointProvider() { 53 IsolatedMountPointProvider::~IsolatedMountPointProvider() {
51 } 54 }
52 55
53 void IsolatedMountPointProvider::ValidateFileSystemRoot( 56 void IsolatedMountPointProvider::ValidateFileSystemRoot(
54 const GURL& origin_url, 57 const GURL& origin_url,
55 FileSystemType type, 58 FileSystemType type,
56 bool create, 59 bool create,
57 const ValidateFileSystemCallback& callback) { 60 const ValidateFileSystemCallback& callback) {
(...skipping 28 matching lines...) Expand all
86 return isolated_context()->CrackIsolatedPath( 89 return isolated_context()->CrackIsolatedPath(
87 virtual_path, &filesystem_id, NULL, &path); 90 virtual_path, &filesystem_id, NULL, &path);
88 } 91 }
89 92
90 bool IsolatedMountPointProvider::IsRestrictedFileName( 93 bool IsolatedMountPointProvider::IsRestrictedFileName(
91 const FilePath& filename) const { 94 const FilePath& filename) const {
92 return false; 95 return false;
93 } 96 }
94 97
95 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil() { 98 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil() {
99 if (true /* FIX THIS */)
100 return media_file_util_.get();
96 return isolated_file_util_.get(); 101 return isolated_file_util_.get();
97 } 102 }
98 103
99 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( 104 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck(
100 const FilePath& virtual_path) const { 105 const FilePath& virtual_path) const {
101 std::string fsid; 106 std::string fsid;
102 FilePath path; 107 FilePath path;
103 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) 108 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path))
104 return FilePath(); 109 return FilePath();
105 return path; 110 return path;
106 } 111 }
107 112
108 FileSystemOperationInterface* 113 FileSystemOperationInterface*
109 IsolatedMountPointProvider::CreateFileSystemOperation( 114 IsolatedMountPointProvider::CreateFileSystemOperation(
110 const FileSystemURL& url, 115 const FileSystemURL& url,
111 FileSystemContext* context) const { 116 FileSystemContext* context) const {
117 if (url.type() /* == kFileSystemMedia*/) {
118 FilePath actual_path = GetPathFromURL(url);
119 if (actual_path.empty())
120 return NULL;
121 FilePath::StringType device_name(actual_path.value());
Lei Zhang 2012/07/25 04:48:29 Let's say we have a device called "usb_foo". The f
kmadhusu 2012/07/27 02:13:40 It is not intentional. I fixed the code to get the
122 MediaDeviceMapService::GetInstance()->AddMediaDevice(device_name);
123 }
112 return new LocalFileSystemOperation(context); 124 return new LocalFileSystemOperation(context);
113 } 125 }
114 126
115 webkit_blob::FileStreamReader* 127 webkit_blob::FileStreamReader*
116 IsolatedMountPointProvider::CreateFileStreamReader( 128 IsolatedMountPointProvider::CreateFileStreamReader(
117 const FileSystemURL& url, 129 const FileSystemURL& url,
118 int64 offset, 130 int64 offset,
119 FileSystemContext* context) const { 131 FileSystemContext* context) const {
120 FilePath path = GetPathFromURL(url); 132 FilePath path = GetPathFromURL(url);
121 return path.empty() ? NULL : new webkit_blob::LocalFileStreamReader( 133 return path.empty() ? NULL : new webkit_blob::LocalFileStreamReader(
122 context->file_task_runner(), path, offset, base::Time()); 134 context->file_task_runner(), path, offset, base::Time());
123 } 135 }
124 136
125 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( 137 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter(
126 const FileSystemURL& url, 138 const FileSystemURL& url,
127 int64 offset, 139 int64 offset,
128 FileSystemContext* context) const { 140 FileSystemContext* context) const {
129 FilePath path = GetPathFromURL(url); 141 FilePath path = GetPathFromURL(url);
130 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset); 142 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset);
131 } 143 }
132 144
133 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { 145 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() {
134 // No quota support. 146 // No quota support.
135 return NULL; 147 return NULL;
136 } 148 }
137 149
138 } // namespace fileapi 150 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/isolated_mount_point_provider.h ('k') | webkit/fileapi/media_device_map_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698