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

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

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/files/file_util_proxy.h" 7 #include "base/files/file_util_proxy.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 void GetFileInfoCallback( 118 void GetFileInfoCallback(
119 scoped_refptr<base::TaskRunner> task_runner, 119 scoped_refptr<base::TaskRunner> task_runner,
120 base::PlatformFile file, 120 base::PlatformFile file,
121 linked_ptr<PP_FileInfo> info, 121 linked_ptr<PP_FileInfo> info,
122 scoped_refptr<TrackedCallback> callback, 122 scoped_refptr<TrackedCallback> callback,
123 base::PlatformFileError error_code, 123 base::PlatformFileError error_code,
124 const base::PlatformFileInfo& file_info) { 124 const base::PlatformFileInfo& file_info) {
125 base::FileUtilProxy::Close( 125 base::FileUtilProxy::Close(
126 task_runner, file, base::Bind(&IgnoreCloseCallback)); 126 task_runner.get(), file, base::Bind(&IgnoreCloseCallback));
127 127
128 if (!TrackedCallback::IsPending(callback)) 128 if (!TrackedCallback::IsPending(callback))
129 return; 129 return;
130 130
131 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 131 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
132 if (pp_error != PP_OK) { 132 if (pp_error != PP_OK) {
133 callback->Run(pp_error); 133 callback->Run(pp_error);
134 return; 134 return;
135 } 135 }
136 136
(...skipping 12 matching lines...) Expand all
149 return; 149 return;
150 150
151 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); 151 int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code);
152 if (pp_error != PP_OK) { 152 if (pp_error != PP_OK) {
153 callback->Run(pp_error); 153 callback->Run(pp_error);
154 return; 154 return;
155 } 155 }
156 base::PlatformFile file = passed_file.ReleaseValue(); 156 base::PlatformFile file = passed_file.ReleaseValue();
157 157
158 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( 158 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile(
159 task_runner, file, 159 task_runner.get(),
160 base::Bind(&GetFileInfoCallback, task_runner, file, info, 160 file,
161 callback))) { 161 base::Bind(
162 &GetFileInfoCallback, task_runner, file, info, callback))) {
162 base::FileUtilProxy::Close( 163 base::FileUtilProxy::Close(
163 task_runner, file, base::Bind(&IgnoreCloseCallback)); 164 task_runner.get(), file, base::Bind(&IgnoreCloseCallback));
164 callback->Run(PP_ERROR_FAILED); 165 callback->Run(PP_ERROR_FAILED);
165 } 166 }
166 } 167 }
167 168
168 void DidReadMetadata( 169 void DidReadMetadata(
169 scoped_refptr< ::ppapi::TrackedCallback> callback, 170 scoped_refptr< ::ppapi::TrackedCallback> callback,
170 linked_ptr<PP_FileInfo> info, 171 linked_ptr<PP_FileInfo> info,
171 PP_FileSystemType file_system_type, 172 PP_FileSystemType file_system_type,
172 const base::PlatformFileInfo& file_info, 173 const base::PlatformFileInfo& file_info,
173 const base::FilePath& unused) { 174 const base::FilePath& unused) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 size_t pos = virtual_path.rfind('/'); 307 size_t pos = virtual_path.rfind('/');
307 CHECK(pos != std::string::npos); 308 CHECK(pos != std::string::npos);
308 309
309 // If the path is "/foo", then we want to include the slash. 310 // If the path is "/foo", then we want to include the slash.
310 if (pos == 0) 311 if (pos == 0)
311 pos++; 312 pos++;
312 std::string parent_path = virtual_path.substr(0, pos); 313 std::string parent_path = virtual_path.substr(0, pos);
313 314
314 scoped_refptr<PPB_FileRef_Impl> parent_ref( 315 scoped_refptr<PPB_FileRef_Impl> parent_ref(
315 CreateInternal(pp_instance(), file_system_, parent_path)); 316 CreateInternal(pp_instance(), file_system_, parent_path));
316 if (!parent_ref) 317 if (!parent_ref.get())
317 return 0; 318 return 0;
318 return parent_ref->GetReference(); 319 return parent_ref->GetReference();
319 } 320 }
320 321
321 int32_t PPB_FileRef_Impl::MakeDirectory( 322 int32_t PPB_FileRef_Impl::MakeDirectory(
322 PP_Bool make_ancestors, 323 PP_Bool make_ancestors,
323 scoped_refptr<TrackedCallback> callback) { 324 scoped_refptr<TrackedCallback> callback) {
324 if (!IsValidNonExternalFileSystem()) 325 if (!IsValidNonExternalFileSystem())
325 return PP_ERROR_NOACCESS; 326 return PP_ERROR_NOACCESS;
326 327
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (!plugin_instance->delegate()->Rename( 387 if (!plugin_instance->delegate()->Rename(
387 GetFileSystemURL(), new_file_ref->GetFileSystemURL(), 388 GetFileSystemURL(), new_file_ref->GetFileSystemURL(),
388 base::Bind(&DidFinishFileOperation, callback))) 389 base::Bind(&DidFinishFileOperation, callback)))
389 return PP_ERROR_FAILED; 390 return PP_ERROR_FAILED;
390 return PP_OK_COMPLETIONPENDING; 391 return PP_OK_COMPLETIONPENDING;
391 } 392 }
392 393
393 PP_Var PPB_FileRef_Impl::GetAbsolutePath() { 394 PP_Var PPB_FileRef_Impl::GetAbsolutePath() {
394 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) 395 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL)
395 return GetPath(); 396 return GetPath();
396 if (!external_path_var_) { 397 if (!external_path_var_.get()) {
397 external_path_var_ = new StringVar( 398 external_path_var_ =
398 external_file_system_path_.AsUTF8Unsafe()); 399 new StringVar(external_file_system_path_.AsUTF8Unsafe());
399 } 400 }
400 return external_path_var_->GetPPVar(); 401 return external_path_var_->GetPPVar();
401 } 402 }
402 403
403 base::FilePath PPB_FileRef_Impl::GetSystemPath() const { 404 base::FilePath PPB_FileRef_Impl::GetSystemPath() const {
404 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) { 405 if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) {
405 NOTREACHED(); 406 NOTREACHED();
406 return base::FilePath(); 407 return base::FilePath();
407 } 408 }
408 return external_file_system_path_; 409 return external_file_system_path_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 scoped_refptr<TrackedCallback> callback) { 455 scoped_refptr<TrackedCallback> callback) {
455 NOTREACHED(); 456 NOTREACHED();
456 return PP_ERROR_FAILED; 457 return PP_ERROR_FAILED;
457 } 458 }
458 459
459 int32_t PPB_FileRef_Impl::QueryInHost( 460 int32_t PPB_FileRef_Impl::QueryInHost(
460 linked_ptr<PP_FileInfo> info, 461 linked_ptr<PP_FileInfo> info,
461 scoped_refptr<TrackedCallback> callback) { 462 scoped_refptr<TrackedCallback> callback) {
462 scoped_refptr<PluginInstance> plugin_instance = 463 scoped_refptr<PluginInstance> plugin_instance =
463 ResourceHelper::GetPluginInstance(this); 464 ResourceHelper::GetPluginInstance(this);
464 if (!plugin_instance) 465 if (!plugin_instance.get())
465 return PP_ERROR_FAILED; 466 return PP_ERROR_FAILED;
466 467
467 if (!file_system_) { 468 if (!file_system_) {
468 // External file system 469 // External file system
469 // We have to do something totally different for external file systems. 470 // We have to do something totally different for external file systems.
470 471
471 // TODO(teravest): Use the SequencedWorkerPool instead. 472 // TODO(teravest): Use the SequencedWorkerPool instead.
472 scoped_refptr<base::TaskRunner> task_runner = 473 scoped_refptr<base::TaskRunner> task_runner =
473 plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); 474 plugin_instance->delegate()->GetFileThreadMessageLoopProxy();
474 if (!plugin_instance->delegate()->AsyncOpenFile( 475 if (!plugin_instance->delegate()->AsyncOpenFile(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 GetFileSystemURL(), 524 GetFileSystemURL(),
524 base::Bind(&DidReadDirectory, 525 base::Bind(&DidReadDirectory,
525 callback, base::Unretained(this), files, file_types), 526 callback, base::Unretained(this), files, file_types),
526 base::Bind(&DidFinishFileOperation, callback))) 527 base::Bind(&DidFinishFileOperation, callback)))
527 return PP_ERROR_FAILED; 528 return PP_ERROR_FAILED;
528 return PP_OK_COMPLETIONPENDING; 529 return PP_OK_COMPLETIONPENDING;
529 } 530 }
530 531
531 } // namespace ppapi 532 } // namespace ppapi
532 } // namespace webkit 533 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_buffer_impl.cc ('k') | webkit/plugins/ppapi/ppb_var_deprecated_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698