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

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: '' 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 29 matching lines...) Expand all
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() {
96 // TODO(kinuko): Return different FileUtil's based on types. 99 // TODO(kinuko): Return different FileUtil's based on types.
100 if (true /* FIX THIS */)
101 return media_file_util_.get();
97 return isolated_file_util_.get(); 102 return isolated_file_util_.get();
98 } 103 }
99 104
100 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( 105 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck(
101 const FilePath& virtual_path) const { 106 const FilePath& virtual_path) const {
102 std::string fsid; 107 std::string fsid;
103 FilePath path; 108 FilePath path;
104 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) 109 if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path))
105 return FilePath(); 110 return FilePath();
106 return path; 111 return path;
107 } 112 }
108 113
109 FileSystemOperationInterface* 114 FileSystemOperationInterface*
110 IsolatedMountPointProvider::CreateFileSystemOperation( 115 IsolatedMountPointProvider::CreateFileSystemOperation(
111 const FileSystemURL& url, 116 const FileSystemURL& url,
112 FileSystemContext* context) const { 117 FileSystemContext* context) const {
118 if (url.type() /* == kFileSystemMedia*/) {
119 std::string fsid;
120 FilePath path;
121 if (!isolated_context()->CrackIsolatedPath(url.path(), &fsid, NULL, &path))
122 return NULL;
123
124 FilePath root_path;
125 if (!isolated_context()->GetRegisteredPath(fsid, &root_path))
126 return NULL;
127 printf("%s\n", __FUNCTION__);
128 MediaDeviceMapService::GetInstance()->AddMediaDevice(root_path.value());
129 }
113 return new LocalFileSystemOperation(context); 130 return new LocalFileSystemOperation(context);
114 } 131 }
115 132
116 webkit_blob::FileStreamReader* 133 webkit_blob::FileStreamReader*
117 IsolatedMountPointProvider::CreateFileStreamReader( 134 IsolatedMountPointProvider::CreateFileStreamReader(
118 const FileSystemURL& url, 135 const FileSystemURL& url,
119 int64 offset, 136 int64 offset,
120 FileSystemContext* context) const { 137 FileSystemContext* context) const {
121 FilePath path = GetPathFromURL(url); 138 FilePath path = GetPathFromURL(url);
122 return path.empty() ? NULL : new webkit_blob::LocalFileStreamReader( 139 return path.empty() ? NULL : new webkit_blob::LocalFileStreamReader(
123 context->file_task_runner(), path, offset, base::Time()); 140 context->file_task_runner(), path, offset, base::Time());
124 } 141 }
125 142
126 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( 143 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter(
127 const FileSystemURL& url, 144 const FileSystemURL& url,
128 int64 offset, 145 int64 offset,
129 FileSystemContext* context) const { 146 FileSystemContext* context) const {
130 FilePath path = GetPathFromURL(url); 147 FilePath path = GetPathFromURL(url);
131 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset); 148 return path.empty() ? NULL : new LocalFileStreamWriter(path, offset);
132 } 149 }
133 150
134 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { 151 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() {
135 // No quota support. 152 // No quota support.
136 return NULL; 153 return NULL;
137 } 154 }
138 155
139 } // namespace fileapi 156 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698