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

Side by Side Diff: content/renderer/pepper/pepper_directory_reader_host.cc

Issue 13726024: Refactor FileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/renderer/pepper/pepper_directory_reader_host.h" 5 #include "content/renderer/pepper/pepper_directory_reader_host.h"
6 6
7 #include "base/callback.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "content/public/renderer/renderer_ppapi_host.h" 11 #include "content/public/renderer/renderer_ppapi_host.h"
12 #include "content/renderer/pepper/null_file_system_callback_dispatcher.h"
11 #include "ppapi/c/pp_errors.h" 13 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/host/dispatch_host_message.h" 14 #include "ppapi/host/dispatch_host_message.h"
13 #include "ppapi/host/ppapi_host.h" 15 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/shared_impl/file_type_conversion.h" 17 #include "ppapi/shared_impl/file_type_conversion.h"
16 #include "ppapi/shared_impl/ppb_file_ref_shared.h" 18 #include "ppapi/shared_impl/ppb_file_ref_shared.h"
17 #include "ppapi/thunk/enter.h" 19 #include "ppapi/thunk/enter.h"
18 #include "webkit/fileapi/file_system_callback_dispatcher.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
21 #include "webkit/plugins/ppapi/resource_helper.h" 21 #include "webkit/plugins/ppapi/resource_helper.h"
22 22
23 using ppapi::thunk::EnterResource; 23 using ppapi::thunk::EnterResource;
24 using ppapi::thunk::PPB_FileRef_API; 24 using ppapi::thunk::PPB_FileRef_API;
25 using webkit::ppapi::PPB_FileRef_Impl; 25 using webkit::ppapi::PPB_FileRef_Impl;
26 26
27 namespace content { 27 namespace content {
28 28
29 namespace { 29 namespace {
30 30
(...skipping 10 matching lines...) Expand all
41 base::FilePath::StringType UTF8StringToFilePathString(const std::string& str) { 41 base::FilePath::StringType UTF8StringToFilePathString(const std::string& str) {
42 #if defined(OS_WIN) 42 #if defined(OS_WIN)
43 return UTF8ToWide(str); 43 return UTF8ToWide(str);
44 #elif defined(OS_POSIX) 44 #elif defined(OS_POSIX)
45 return str; 45 return str;
46 #else 46 #else
47 #error "Unsupported platform." 47 #error "Unsupported platform."
48 #endif 48 #endif
49 } 49 }
50 50
51 class ReadDirectoryCallback : public fileapi::FileSystemCallbackDispatcher { 51 class ReadDirectoryCallback : public NullFileSystemCallbackDispatcher {
52 public: 52 public:
53 typedef base::Callback<void (const PepperDirectoryReaderHost::Entries&, 53 typedef base::Callback<void (const PepperDirectoryReaderHost::Entries&,
54 bool, int32_t)> 54 bool, int32_t)>
55 OnReadDirectoryCallback; 55 OnReadDirectoryCallback;
56 56
57 explicit ReadDirectoryCallback(const OnReadDirectoryCallback& callback) 57 explicit ReadDirectoryCallback(const OnReadDirectoryCallback& callback)
58 : callback_(callback) {} 58 : callback_(callback) {}
59 virtual ~ReadDirectoryCallback() {} 59 virtual ~ReadDirectoryCallback() {}
60 60
61 virtual void DidSucceed() OVERRIDE {
62 NOTREACHED();
63 }
64
65 virtual void DidReadMetadata(const base::PlatformFileInfo& file_info,
66 const base::FilePath& platform_path) OVERRIDE {
67 NOTREACHED();
68 }
69
70 virtual void DidCreateSnapshotFile(
71 const base::PlatformFileInfo& file_info,
72 const base::FilePath& platform_path) OVERRIDE {
73 NOTREACHED();
74 }
75
76 virtual void DidReadDirectory( 61 virtual void DidReadDirectory(
77 const std::vector<base::FileUtilProxy::Entry>& entries, 62 const std::vector<base::FileUtilProxy::Entry>& entries,
78 bool has_more) OVERRIDE { 63 bool has_more) OVERRIDE {
79 callback_.Run(entries, has_more, PP_OK); 64 callback_.Run(entries, has_more, PP_OK);
80 } 65 }
81 66
82 virtual void DidOpenFileSystem(const std::string& name, 67 virtual void DidFail(int pp_error) OVERRIDE {
yzshen1 2013/04/08 21:05:16 int32_t, please.
victorhsieh 2013/04/08 23:44:38 Done.
83 const GURL& root) OVERRIDE { 68 callback_.Run(PepperDirectoryReaderHost::Entries(), false, pp_error);
84 NOTREACHED();
85 }
86
87 virtual void DidFail(base::PlatformFileError error) OVERRIDE {
88 callback_.Run(PepperDirectoryReaderHost::Entries(),
89 false,
90 ppapi::PlatformFileErrorToPepperError(error));
91 }
92
93 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
94 NOTREACHED();
95 }
96
97 virtual void DidOpenFile(base::PlatformFile file) OVERRIDE {
98 NOTREACHED();
99 } 69 }
100 70
101 private: 71 private:
102 OnReadDirectoryCallback callback_; 72 OnReadDirectoryCallback callback_;
103 }; 73 };
104 74
105 } // namespace 75 } // namespace
106 76
107 PepperDirectoryReaderHost::PepperDirectoryReaderHost( 77 PepperDirectoryReaderHost::PepperDirectoryReaderHost(
108 RendererPpapiHost* host, 78 RendererPpapiHost* host,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 std::string dir_path = directory_ref_->GetCreateInfo().path; 137 std::string dir_path = directory_ref_->GetCreateInfo().path;
168 if (dir_path[dir_path.size() - 1] != '/') 138 if (dir_path[dir_path.size() - 1] != '/')
169 dir_path += '/'; 139 dir_path += '/';
170 base::FilePath::StringType dir_file_path = 140 base::FilePath::StringType dir_file_path =
171 UTF8StringToFilePathString(dir_path); 141 UTF8StringToFilePathString(dir_path);
172 142
173 for (Entries::const_iterator it = entries.begin(); 143 for (Entries::const_iterator it = entries.begin();
174 it != entries.end(); ++it) { 144 it != entries.end(); ++it) {
175 EntryData data; 145 EntryData data;
176 data.file_ref = PPB_FileRef_Impl::CreateInternal( 146 data.file_ref = PPB_FileRef_Impl::CreateInternal(
177 directory_ref_->file_system()->pp_resource(), 147 pp_instance(),
148 directory_ref_->file_system_resource(),
178 FilePathStringToUTF8String(dir_file_path + it->name)); 149 FilePathStringToUTF8String(dir_file_path + it->name));
179 if (!data.file_ref) { 150 if (!data.file_ref) {
180 entry_data_.clear(); 151 entry_data_.clear();
181 return false; 152 return false;
182 } 153 }
183 data.file_type = it->is_directory ? 154 data.file_type = it->is_directory ?
184 PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR; 155 PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR;
185 entry_data_.push_back(data); 156 entry_data_.push_back(data);
186 } 157 }
187 158
(...skipping 20 matching lines...) Expand all
208 file_types)); 179 file_types));
209 } 180 }
210 181
211 PepperDirectoryReaderHost::EntryData::EntryData() { 182 PepperDirectoryReaderHost::EntryData::EntryData() {
212 } 183 }
213 184
214 PepperDirectoryReaderHost::EntryData::~EntryData() { 185 PepperDirectoryReaderHost::EntryData::~EntryData() {
215 } 186 }
216 187
217 } // namespace content 188 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698