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

Side by Side Diff: storage/browser/fileapi/dragged_file_util.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "webkit/browser/fileapi/dragged_file_util.h" 5 #include "storage/browser/fileapi/dragged_file_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "webkit/browser/fileapi/file_system_context.h" 11 #include "storage/browser/fileapi/file_system_context.h"
12 #include "webkit/browser/fileapi/file_system_operation_context.h" 12 #include "storage/browser/fileapi/file_system_operation_context.h"
13 #include "webkit/browser/fileapi/file_system_url.h" 13 #include "storage/browser/fileapi/file_system_url.h"
14 #include "webkit/browser/fileapi/isolated_context.h" 14 #include "storage/browser/fileapi/isolated_context.h"
15 #include "webkit/browser/fileapi/native_file_util.h" 15 #include "storage/browser/fileapi/native_file_util.h"
16 #include "webkit/common/blob/shareable_file_reference.h" 16 #include "storage/common/blob/shareable_file_reference.h"
17 17
18 namespace fileapi { 18 namespace storage {
19 19
20 typedef IsolatedContext::MountPointInfo FileInfo; 20 typedef IsolatedContext::MountPointInfo FileInfo;
21 21
22 namespace { 22 namespace {
23 23
24 // Simply enumerate each path from a given fileinfo set. 24 // Simply enumerate each path from a given fileinfo set.
25 // Used to enumerate top-level paths of an isolated filesystem. 25 // Used to enumerate top-level paths of an isolated filesystem.
26 class SetFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator { 26 class SetFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
27 public: 27 public:
28 explicit SetFileEnumerator(const std::vector<FileInfo>& files) 28 explicit SetFileEnumerator(const std::vector<FileInfo>& files)
(...skipping 19 matching lines...) Expand all
48 private: 48 private:
49 std::vector<FileInfo> files_; 49 std::vector<FileInfo> files_;
50 std::vector<FileInfo>::const_iterator file_iter_; 50 std::vector<FileInfo>::const_iterator file_iter_;
51 base::File::Info file_info_; 51 base::File::Info file_info_;
52 }; 52 };
53 53
54 } // namespace 54 } // namespace
55 55
56 //------------------------------------------------------------------------- 56 //-------------------------------------------------------------------------
57 57
58 DraggedFileUtil::DraggedFileUtil() {} 58 DraggedFileUtil::DraggedFileUtil() {
59 }
59 60
60 base::File::Error DraggedFileUtil::GetFileInfo( 61 base::File::Error DraggedFileUtil::GetFileInfo(
61 FileSystemOperationContext* context, 62 FileSystemOperationContext* context,
62 const FileSystemURL& url, 63 const FileSystemURL& url,
63 base::File::Info* file_info, 64 base::File::Info* file_info,
64 base::FilePath* platform_path) { 65 base::FilePath* platform_path) {
65 DCHECK(file_info); 66 DCHECK(file_info);
66 std::string filesystem_id; 67 std::string filesystem_id;
67 DCHECK(url.is_valid()); 68 DCHECK(url.is_valid());
68 if (url.path().empty()) { 69 if (url.path().empty()) {
69 // The root directory case. 70 // The root directory case.
70 // For now we leave three time fields (modified/accessed/creation time) 71 // For now we leave three time fields (modified/accessed/creation time)
71 // NULL as it is not really clear what to be set for this virtual directory. 72 // NULL as it is not really clear what to be set for this virtual directory.
72 // TODO(kinuko): Maybe we want to set the time when this filesystem is 73 // TODO(kinuko): Maybe we want to set the time when this filesystem is
73 // created (i.e. when the files/directories are dropped). 74 // created (i.e. when the files/directories are dropped).
74 file_info->is_directory = true; 75 file_info->is_directory = true;
75 file_info->is_symbolic_link = false; 76 file_info->is_symbolic_link = false;
76 file_info->size = 0; 77 file_info->size = 0;
77 return base::File::FILE_OK; 78 return base::File::FILE_OK;
78 } 79 }
79 base::File::Error error = 80 base::File::Error error = NativeFileUtil::GetFileInfo(url.path(), file_info);
80 NativeFileUtil::GetFileInfo(url.path(), file_info);
81 if (base::IsLink(url.path()) && !base::FilePath().IsParent(url.path())) { 81 if (base::IsLink(url.path()) && !base::FilePath().IsParent(url.path())) {
82 // Don't follow symlinks unless it's the one that are selected by the user. 82 // Don't follow symlinks unless it's the one that are selected by the user.
83 return base::File::FILE_ERROR_NOT_FOUND; 83 return base::File::FILE_ERROR_NOT_FOUND;
84 } 84 }
85 if (error == base::File::FILE_OK) 85 if (error == base::File::FILE_OK)
86 *platform_path = url.path(); 86 *platform_path = url.path();
87 return error; 87 return error;
88 } 88 }
89 89
90 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> 90 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
91 DraggedFileUtil::CreateFileEnumerator( 91 DraggedFileUtil::CreateFileEnumerator(FileSystemOperationContext* context,
92 FileSystemOperationContext* context, 92 const FileSystemURL& root) {
93 const FileSystemURL& root) {
94 DCHECK(root.is_valid()); 93 DCHECK(root.is_valid());
95 if (!root.path().empty()) 94 if (!root.path().empty())
96 return LocalFileUtil::CreateFileEnumerator(context, root); 95 return LocalFileUtil::CreateFileEnumerator(context, root);
97 96
98 // Root path case. 97 // Root path case.
99 std::vector<FileInfo> toplevels; 98 std::vector<FileInfo> toplevels;
100 IsolatedContext::GetInstance()->GetDraggedFileInfo( 99 IsolatedContext::GetInstance()->GetDraggedFileInfo(root.filesystem_id(),
101 root.filesystem_id(), &toplevels); 100 &toplevels);
102 return scoped_ptr<AbstractFileEnumerator>(new SetFileEnumerator(toplevels)); 101 return scoped_ptr<AbstractFileEnumerator>(new SetFileEnumerator(toplevels));
103 } 102 }
104 103
105 } // namespace fileapi 104 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/dragged_file_util.h ('k') | storage/browser/fileapi/dump_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698