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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc

Issue 190423002: Correctly handle has_more in PepperInternalFileRefBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend. h" 5 #include "content/browser/renderer_host/pepper/pepper_internal_file_ref_backend. h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 host_->SendReply(reply_context, 191 host_->SendReply(reply_context,
192 PpapiPluginMsg_FileRef_QueryReply(pp_file_info)); 192 PpapiPluginMsg_FileRef_QueryReply(pp_file_info));
193 } 193 }
194 194
195 int32_t PepperInternalFileRefBackend::ReadDirectoryEntries( 195 int32_t PepperInternalFileRefBackend::ReadDirectoryEntries(
196 ppapi::host::ReplyMessageContext reply_context) { 196 ppapi::host::ReplyMessageContext reply_context) {
197 if (!GetFileSystemURL().is_valid()) 197 if (!GetFileSystemURL().is_valid())
198 return PP_ERROR_FAILED; 198 return PP_ERROR_FAILED;
199 199
200 fileapi::FileSystemOperation::FileEntryList* accumulated_file_list
201 = new fileapi::FileSystemOperation::FileEntryList;
200 GetFileSystemContext()->operation_runner()->ReadDirectory( 202 GetFileSystemContext()->operation_runner()->ReadDirectory(
201 GetFileSystemURL(), 203 GetFileSystemURL(),
202 base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete, 204 base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete,
203 weak_factory_.GetWeakPtr(), 205 weak_factory_.GetWeakPtr(),
204 reply_context)); 206 reply_context,
207 base::Owned(accumulated_file_list)));
205 return PP_OK_COMPLETIONPENDING; 208 return PP_OK_COMPLETIONPENDING;
206 } 209 }
207 210
208 void PepperInternalFileRefBackend::ReadDirectoryComplete( 211 void PepperInternalFileRefBackend::ReadDirectoryComplete(
209 ppapi::host::ReplyMessageContext context, 212 ppapi::host::ReplyMessageContext context,
213 fileapi::FileSystemOperation::FileEntryList* accumulated_file_list,
210 base::File::Error error, 214 base::File::Error error,
211 const fileapi::FileSystemOperation::FileEntryList& file_list, 215 const fileapi::FileSystemOperation::FileEntryList& file_list,
212 bool has_more) { 216 bool has_more) {
213 // The current filesystem backend always returns false. 217 accumulated_file_list->insert(accumulated_file_list->end(),
214 DCHECK(!has_more); 218 file_list.begin(), file_list.end());
219 if (has_more)
220 return;
215 221
216 context.params.set_result(ppapi::FileErrorToPepperError(error)); 222 context.params.set_result(ppapi::FileErrorToPepperError(error));
217 223
218 std::vector<ppapi::FileRefCreateInfo> infos; 224 std::vector<ppapi::FileRefCreateInfo> infos;
219 std::vector<PP_FileType> file_types; 225 std::vector<PP_FileType> file_types;
220 if (error == base::File::FILE_OK && fs_host_.get()) { 226 if (error == base::File::FILE_OK && fs_host_.get()) {
221 std::string dir_path = path_; 227 std::string dir_path = path_;
222 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/') 228 if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/')
223 dir_path += '/'; 229 dir_path += '/';
224 230
225 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = 231 for (fileapi::FileSystemOperation::FileEntryList::const_iterator it =
226 file_list.begin(); it != file_list.end(); ++it) { 232 accumulated_file_list->begin();
233 it != accumulated_file_list->end(); ++it) {
227 if (it->is_directory) 234 if (it->is_directory)
228 file_types.push_back(PP_FILETYPE_DIRECTORY); 235 file_types.push_back(PP_FILETYPE_DIRECTORY);
229 else 236 else
230 file_types.push_back(PP_FILETYPE_REGULAR); 237 file_types.push_back(PP_FILETYPE_REGULAR);
231 238
232 ppapi::FileRefCreateInfo info; 239 ppapi::FileRefCreateInfo info;
233 info.file_system_type = fs_type_; 240 info.file_system_type = fs_type_;
234 info.file_system_plugin_resource = fs_host_->pp_resource(); 241 info.file_system_plugin_resource = fs_host_->pp_resource();
235 std::string path = 242 std::string path =
236 dir_path + fileapi::FilePathToString(base::FilePath(it->name)); 243 dir_path + fileapi::FilePathToString(base::FilePath(it->name));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ChildProcessSecurityPolicyImpl* policy = 298 ChildProcessSecurityPolicyImpl* policy =
292 ChildProcessSecurityPolicyImpl::GetInstance(); 299 ChildProcessSecurityPolicyImpl::GetInstance();
293 if (!policy->CanReadFileSystemFile(render_process_id_, url) || 300 if (!policy->CanReadFileSystemFile(render_process_id_, url) ||
294 !policy->CanWriteFileSystemFile(render_process_id_, url)) { 301 !policy->CanWriteFileSystemFile(render_process_id_, url)) {
295 return PP_ERROR_NOACCESS; 302 return PP_ERROR_NOACCESS;
296 } 303 }
297 return PP_OK; 304 return PP_OK;
298 } 305 }
299 306
300 } // namespace content 307 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698