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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated TestURLLoader to test blocking callbacks. Created 8 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 | 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_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"
11 #include "ppapi/c/dev/ppb_directory_reader_dev.h" 11 #include "ppapi/c/dev/ppb_directory_reader_dev.h"
12 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h" 13 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/thunk/enter.h" 14 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_file_ref_api.h" 15 #include "ppapi/thunk/ppb_file_ref_api.h"
16 #include "webkit/plugins/ppapi/common.h" 16 #include "webkit/plugins/ppapi/common.h"
17 #include "webkit/plugins/ppapi/file_callbacks.h" 17 #include "webkit/plugins/ppapi/file_callbacks.h"
18 #include "webkit/plugins/ppapi/plugin_delegate.h" 18 #include "webkit/plugins/ppapi/plugin_delegate.h"
19 #include "webkit/plugins/ppapi/plugin_module.h" 19 #include "webkit/plugins/ppapi/plugin_module.h"
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
21 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" 21 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
22 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" 22 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
23 #include "webkit/plugins/ppapi/resource_helper.h" 23 #include "webkit/plugins/ppapi/resource_helper.h"
24 24
25 using ppapi::ApiCallbackType;
25 using ::ppapi::PpapiGlobals; 26 using ::ppapi::PpapiGlobals;
26 using ::ppapi::thunk::EnterResourceNoLock; 27 using ::ppapi::thunk::EnterResourceNoLock;
27 using ::ppapi::thunk::PPB_DirectoryReader_API; 28 using ::ppapi::thunk::PPB_DirectoryReader_API;
28 using ::ppapi::thunk::PPB_FileRef_API; 29 using ::ppapi::thunk::PPB_FileRef_API;
29 30
30 namespace webkit { 31 namespace webkit {
31 namespace ppapi { 32 namespace ppapi {
32 33
33 namespace { 34 namespace {
34 35
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (enter.failed()) 72 if (enter.failed())
72 return 0; 73 return 0;
73 return (new PPB_DirectoryReader_Impl( 74 return (new PPB_DirectoryReader_Impl(
74 static_cast<PPB_FileRef_Impl*>(enter.object())))->GetReference(); 75 static_cast<PPB_FileRef_Impl*>(enter.object())))->GetReference();
75 } 76 }
76 77
77 PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() { 78 PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
78 return this; 79 return this;
79 } 80 }
80 81
81 int32_t PPB_DirectoryReader_Impl::GetNextEntry( 82 int32_t PPB_DirectoryReader_Impl::GetNextEntry(PP_DirectoryEntry_Dev* entry,
82 PP_DirectoryEntry_Dev* entry, 83 ApiCallbackType callback) {
83 PP_CompletionCallback callback) {
84 if (!callback.func)
85 return PP_ERROR_BLOCKS_MAIN_THREAD;
86 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 84 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
87 return PP_ERROR_FAILED; 85 return PP_ERROR_FAILED;
88 86
89 entry_ = entry; 87 entry_ = entry;
90 if (FillUpEntry()) { 88 if (FillUpEntry()) {
91 entry_ = NULL; 89 entry_ = NULL;
92 return PP_OK; 90 return PP_OK;
93 } 91 }
94 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 92 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
95 if (!plugin_instance) 93 if (!plugin_instance)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (!has_more_) { 146 if (!has_more_) {
149 entry_->file_ref = 0; 147 entry_->file_ref = 0;
150 return true; 148 return true;
151 } 149 }
152 150
153 return false; 151 return false;
154 } 152 }
155 153
156 } // namespace ppapi 154 } // namespace ppapi
157 } // namespace webkit 155 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698