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

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

Issue 9015009: Use the new callback tracker and delete the old one (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 12 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_file_ref_impl.h" 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!callback.func) 166 if (!callback.func)
167 return PP_ERROR_BLOCKS_MAIN_THREAD; 167 return PP_ERROR_BLOCKS_MAIN_THREAD;
168 if (!IsValidNonExternalFileSystem()) 168 if (!IsValidNonExternalFileSystem())
169 return PP_ERROR_NOACCESS; 169 return PP_ERROR_NOACCESS;
170 170
171 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 171 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
172 if (!plugin_instance) 172 if (!plugin_instance)
173 return PP_ERROR_FAILED; 173 return PP_ERROR_FAILED;
174 if (!plugin_instance->delegate()->MakeDirectory( 174 if (!plugin_instance->delegate()->MakeDirectory(
175 GetFileSystemURL(), PP_ToBool(make_ancestors), 175 GetFileSystemURL(), PP_ToBool(make_ancestors),
176 new FileCallbacks(plugin_instance->module()->AsWeakPtr(), 176 new FileCallbacks(this, callback, NULL, NULL, NULL)))
177 pp_resource(), callback, NULL, NULL, NULL)))
178 return PP_ERROR_FAILED; 177 return PP_ERROR_FAILED;
179 return PP_OK_COMPLETIONPENDING; 178 return PP_OK_COMPLETIONPENDING;
180 } 179 }
181 180
182 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, 181 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
183 PP_Time last_modified_time, 182 PP_Time last_modified_time,
184 PP_CompletionCallback callback) { 183 PP_CompletionCallback callback) {
185 if (!callback.func) 184 if (!callback.func)
186 return PP_ERROR_BLOCKS_MAIN_THREAD; 185 return PP_ERROR_BLOCKS_MAIN_THREAD;
187 if (!IsValidNonExternalFileSystem()) 186 if (!IsValidNonExternalFileSystem())
188 return PP_ERROR_NOACCESS; 187 return PP_ERROR_NOACCESS;
189 188
190 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 189 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
191 if (!plugin_instance) 190 if (!plugin_instance)
192 return PP_ERROR_FAILED; 191 return PP_ERROR_FAILED;
193 if (!plugin_instance->delegate()->Touch( 192 if (!plugin_instance->delegate()->Touch(
194 GetFileSystemURL(), 193 GetFileSystemURL(),
195 PPTimeToTime(last_access_time), 194 PPTimeToTime(last_access_time),
196 PPTimeToTime(last_modified_time), 195 PPTimeToTime(last_modified_time),
197 new FileCallbacks(plugin_instance->module()->AsWeakPtr(), 196 new FileCallbacks(this, callback, NULL, NULL, NULL)))
198 pp_resource(), callback, NULL, NULL, NULL)))
199 return PP_ERROR_FAILED; 197 return PP_ERROR_FAILED;
200 return PP_OK_COMPLETIONPENDING; 198 return PP_OK_COMPLETIONPENDING;
201 } 199 }
202 200
203 int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) { 201 int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
204 if (!callback.func) 202 if (!callback.func)
205 return PP_ERROR_BLOCKS_MAIN_THREAD; 203 return PP_ERROR_BLOCKS_MAIN_THREAD;
206 if (!IsValidNonExternalFileSystem()) 204 if (!IsValidNonExternalFileSystem())
207 return PP_ERROR_NOACCESS; 205 return PP_ERROR_NOACCESS;
208 206
209 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 207 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
210 if (!plugin_instance) 208 if (!plugin_instance)
211 return PP_ERROR_FAILED; 209 return PP_ERROR_FAILED;
212 if (!plugin_instance->delegate()->Delete( 210 if (!plugin_instance->delegate()->Delete(
213 GetFileSystemURL(), 211 GetFileSystemURL(),
214 new FileCallbacks(plugin_instance->module()->AsWeakPtr(), 212 new FileCallbacks(this, callback, NULL, NULL, NULL)))
215 pp_resource(), callback, NULL, NULL, NULL)))
216 return PP_ERROR_FAILED; 213 return PP_ERROR_FAILED;
217 return PP_OK_COMPLETIONPENDING; 214 return PP_OK_COMPLETIONPENDING;
218 } 215 }
219 216
220 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref, 217 int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
221 PP_CompletionCallback callback) { 218 PP_CompletionCallback callback) {
222 if (!callback.func) 219 if (!callback.func)
223 return PP_ERROR_BLOCKS_MAIN_THREAD; 220 return PP_ERROR_BLOCKS_MAIN_THREAD;
224 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true); 221 EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true);
225 if (enter.failed()) 222 if (enter.failed())
226 return PP_ERROR_BADRESOURCE; 223 return PP_ERROR_BADRESOURCE;
227 PPB_FileRef_Impl* new_file_ref = 224 PPB_FileRef_Impl* new_file_ref =
228 static_cast<PPB_FileRef_Impl*>(enter.object()); 225 static_cast<PPB_FileRef_Impl*>(enter.object());
229 226
230 if (!IsValidNonExternalFileSystem() || 227 if (!IsValidNonExternalFileSystem() ||
231 file_system_.get() != new_file_ref->file_system_.get()) 228 file_system_.get() != new_file_ref->file_system_.get())
232 return PP_ERROR_NOACCESS; 229 return PP_ERROR_NOACCESS;
233 230
234 // TODO(viettrungluu): Also cancel when the new file ref is destroyed? 231 // TODO(viettrungluu): Also cancel when the new file ref is destroyed?
235 // http://crbug.com/67624 232 // http://crbug.com/67624
236 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 233 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
237 if (!plugin_instance) 234 if (!plugin_instance)
238 return PP_ERROR_FAILED; 235 return PP_ERROR_FAILED;
239 if (!plugin_instance->delegate()->Rename( 236 if (!plugin_instance->delegate()->Rename(
240 GetFileSystemURL(), new_file_ref->GetFileSystemURL(), 237 GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
241 new FileCallbacks(plugin_instance->module()->AsWeakPtr(), 238 new FileCallbacks(this, callback, NULL, NULL, NULL)))
242 pp_resource(), callback, NULL, NULL, NULL)))
243 return PP_ERROR_FAILED; 239 return PP_ERROR_FAILED;
244 return PP_OK_COMPLETIONPENDING; 240 return PP_OK_COMPLETIONPENDING;
245 } 241 }
246 242
247 PP_Var PPB_FileRef_Impl::GetAbsolutePath() { 243 PP_Var PPB_FileRef_Impl::GetAbsolutePath() {
248 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) 244 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL)
249 return GetPath(); 245 return GetPath();
250 if (!external_path_var_.get()) { 246 if (!external_path_var_.get()) {
251 external_path_var_ = new StringVar( 247 external_path_var_ = new StringVar(
252 external_file_system_path_.AsUTF8Unsafe()); 248 external_file_system_path_.AsUTF8Unsafe());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return file_system_ && file_system_->opened(); 281 return file_system_ && file_system_->opened();
286 } 282 }
287 283
288 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { 284 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
289 return file_system_ && file_system_->opened() && 285 return file_system_ && file_system_->opened() &&
290 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; 286 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL;
291 } 287 }
292 288
293 } // namespace ppapi 289 } // namespace ppapi
294 } // namespace webkit 290 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698