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

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

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

Powered by Google App Engine
This is Rietveld 408576698