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

Side by Side Diff: webkit/plugins/ppapi/ppb_directory_reader_impl.cc

Issue 6286038: Add initial code to do filename munging in the FileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/plugins/ppapi/ppb_directory_reader_impl.h" 5 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 directory_ref_->GetSystemPath(), 116 directory_ref_->GetSystemPath(),
117 new FileCallbacks(instance->module()->AsWeakPtr(), 117 new FileCallbacks(instance->module()->AsWeakPtr(),
118 resource_id, 118 resource_id,
119 callback, NULL, NULL, this))) 119 callback, NULL, NULL, this)))
120 return PP_ERROR_FAILED; 120 return PP_ERROR_FAILED;
121 121
122 return PP_ERROR_WOULDBLOCK; 122 return PP_ERROR_WOULDBLOCK;
123 } 123 }
124 124
125 void PPB_DirectoryReader_Impl::AddNewEntries( 125 void PPB_DirectoryReader_Impl::AddNewEntries(
126 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { 126 const std::vector<base::FileUtilProxyBase::Entry>& entries, bool has_more) {
127 DCHECK(!entries.empty()); 127 DCHECK(!entries.empty());
128 has_more_ = has_more; 128 has_more_ = has_more;
129 std::string dir_path = directory_ref_->GetPath(); 129 std::string dir_path = directory_ref_->GetPath();
130 if (dir_path[dir_path.size() - 1] != '/') 130 if (dir_path[dir_path.size() - 1] != '/')
131 dir_path += '/'; 131 dir_path += '/';
132 FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path); 132 FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path);
133 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it = 133 for (std::vector<base::FileUtilProxyBase::Entry>::const_iterator it =
134 entries.begin(); it != entries.end(); it++) { 134 entries.begin(); it != entries.end(); it++) {
135 base::FileUtilProxy::Entry entry; 135 base::FileUtilProxyBase::Entry entry;
136 entry.name = dir_file_path + it->name; 136 entry.name = dir_file_path + it->name;
137 entry.is_directory = it->is_directory; 137 entry.is_directory = it->is_directory;
138 entries_.push(entry); 138 entries_.push(entry);
139 } 139 }
140 140
141 FillUpEntry(); 141 FillUpEntry();
142 entry_ = NULL; 142 entry_ = NULL;
143 } 143 }
144 144
145 bool PPB_DirectoryReader_Impl::FillUpEntry() { 145 bool PPB_DirectoryReader_Impl::FillUpEntry() {
146 DCHECK(entry_); 146 DCHECK(entry_);
147 if (!entries_.empty()) { 147 if (!entries_.empty()) {
148 base::FileUtilProxy::Entry dir_entry = entries_.front(); 148 base::FileUtilProxyBase::Entry dir_entry = entries_.front();
149 entries_.pop(); 149 entries_.pop();
150 if (entry_->file_ref) 150 if (entry_->file_ref)
151 ResourceTracker::Get()->UnrefResource(entry_->file_ref); 151 ResourceTracker::Get()->UnrefResource(entry_->file_ref);
152 PPB_FileRef_Impl* file_ref = 152 PPB_FileRef_Impl* file_ref =
153 new PPB_FileRef_Impl(instance(), directory_ref_->GetFileSystem(), 153 new PPB_FileRef_Impl(instance(), directory_ref_->GetFileSystem(),
154 FilePathStringToUTF8String(dir_entry.name)); 154 FilePathStringToUTF8String(dir_entry.name));
155 entry_->file_ref = file_ref->GetReference(); 155 entry_->file_ref = file_ref->GetReference();
156 entry_->file_type = 156 entry_->file_type =
157 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); 157 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
158 return true; 158 return true;
159 } 159 }
160 160
161 if (!has_more_) { 161 if (!has_more_) {
162 entry_->file_ref = 0; 162 entry_->file_ref = 0;
163 return true; 163 return true;
164 } 164 }
165 165
166 return false; 166 return false;
167 } 167 }
168 168
169 } // namespace ppapi 169 } // namespace ppapi
170 } // namespace webkit 170 } // namespace webkit
171 171
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698