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

Side by Side Diff: webkit/chromeos/fileapi/cros_mount_point_provider.cc

Issue 7470037: [Refactor] to rename and re-layer the file_util stack layers. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased on the svn tree. Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/fileapi/cros_mount_point_provider.h" 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_callback_factory.h" 8 #include "base/memory/scoped_callback_factory.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
19 #include "webkit/chromeos/fileapi/file_access_permissions.h" 19 #include "webkit/chromeos/fileapi/file_access_permissions.h"
20 #include "webkit/fileapi/file_system_file_util.h"
21 #include "webkit/fileapi/file_system_path_manager.h" 20 #include "webkit/fileapi/file_system_path_manager.h"
22 #include "webkit/fileapi/file_system_util.h" 21 #include "webkit/fileapi/file_system_util.h"
22 #include "webkit/fileapi/native_file_util.h"
23 #include "webkit/glue/webkit_glue.h" 23 #include "webkit/glue/webkit_glue.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 typedef struct { 27 typedef struct {
28 const char* local_root_path; 28 const char* local_root_path;
29 const char* web_root_path; 29 const char* web_root_path;
30 } FixedExposedPaths; 30 } FixedExposedPaths;
31 31
32 const char kChromeUIScheme[] = "chrome"; 32 const char kChromeUIScheme[] = "chrome";
33 33
34 // Top level file system elements exposed in FileAPI in ChromeOS: 34 // Top level file system elements exposed in FileAPI in ChromeOS:
35 FixedExposedPaths fixed_exposed_paths[] = { 35 FixedExposedPaths fixed_exposed_paths[] = {
36 {"/home/chronos/user/", "Downloads"}, 36 {"/home/chronos/user/", "Downloads"},
37 {"/media", "archive"}, 37 {"/media", "archive"},
38 {"/media", "removable"}, 38 {"/media", "removable"},
39 }; 39 };
40 40
41 CrosMountPointProvider::CrosMountPointProvider( 41 CrosMountPointProvider::CrosMountPointProvider(
42 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) 42 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy)
43 : special_storage_policy_(special_storage_policy), 43 : special_storage_policy_(special_storage_policy),
44 file_access_permissions_(new FileAccessPermissions()), 44 file_access_permissions_(new FileAccessPermissions()),
45 local_file_util_(new fileapi::LocalFileSystemFileUtil( 45 local_file_util_(
46 new fileapi::FileSystemFileUtil())) { 46 new fileapi::LocalFileUtil(new fileapi::NativeFileUtil())) {
47 for (size_t i = 0; i < arraysize(fixed_exposed_paths); i++) { 47 for (size_t i = 0; i < arraysize(fixed_exposed_paths); i++) {
48 mount_point_map_.insert(std::pair<std::string, FilePath>( 48 mount_point_map_.insert(std::pair<std::string, FilePath>(
49 std::string(fixed_exposed_paths[i].web_root_path), 49 std::string(fixed_exposed_paths[i].web_root_path),
50 FilePath(std::string(fixed_exposed_paths[i].local_root_path)))); 50 FilePath(std::string(fixed_exposed_paths[i].local_root_path))));
51 } 51 }
52 } 52 }
53 53
54 CrosMountPointProvider::~CrosMountPointProvider() { 54 CrosMountPointProvider::~CrosMountPointProvider() {
55 } 55 }
56 56
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const { 171 std::vector<FilePath> CrosMountPointProvider::GetRootDirectories() const {
172 std::vector<FilePath> root_dirs; 172 std::vector<FilePath> root_dirs;
173 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); 173 for (MountPointMap::const_iterator iter = mount_point_map_.begin();
174 iter != mount_point_map_.end(); 174 iter != mount_point_map_.end();
175 ++iter) { 175 ++iter) {
176 root_dirs.push_back(iter->second.Append(iter->first)); 176 root_dirs.push_back(iter->second.Append(iter->first));
177 } 177 }
178 return root_dirs; 178 return root_dirs;
179 } 179 }
180 180
181 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileSystemFileUtil() { 181 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil() {
182 return local_file_util_.get(); 182 return local_file_util_.get();
183 } 183 }
184 184
185 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, 185 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path,
186 FilePath* virtual_path) { 186 FilePath* virtual_path) {
187 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); 187 for (MountPointMap::const_iterator iter = mount_point_map_.begin();
188 iter != mount_point_map_.end(); 188 iter != mount_point_map_.end();
189 ++iter) { 189 ++iter) {
190 FilePath mount_prefix = iter->second.Append(iter->first); 190 FilePath mount_prefix = iter->second.Append(iter->first);
191 *virtual_path = FilePath(iter->first); 191 *virtual_path = FilePath(iter->first);
192 if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { 192 if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) {
193 return true; 193 return true;
194 } else if (mount_prefix == filesystem_path) { 194 } else if (mount_prefix == filesystem_path) {
195 FilePath root = FilePath(FILE_PATH_LITERAL("/")); 195 FilePath root = FilePath(FILE_PATH_LITERAL("/"));
196 *virtual_path = root.Append(iter->first); 196 *virtual_path = root.Append(iter->first);
197 return true; 197 return true;
198 } 198 }
199 } 199 }
200 return false; 200 return false;
201 } 201 }
202 202
203 } // namespace chromeos 203 } // namespace chromeos
OLDNEW
« no previous file with comments | « webkit/chromeos/fileapi/cros_mount_point_provider.h ('k') | webkit/fileapi/file_system_dir_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698