OLD | NEW |
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_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/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
13 #include "ppapi/thunk/ppb_file_ref_api.h" | 14 #include "ppapi/thunk/ppb_file_ref_api.h" |
14 #include "webkit/plugins/ppapi/common.h" | 15 #include "webkit/plugins/ppapi/common.h" |
15 #include "webkit/plugins/ppapi/file_callbacks.h" | 16 #include "webkit/plugins/ppapi/file_callbacks.h" |
16 #include "webkit/plugins/ppapi/plugin_delegate.h" | 17 #include "webkit/plugins/ppapi/plugin_delegate.h" |
17 #include "webkit/plugins/ppapi/plugin_module.h" | 18 #include "webkit/plugins/ppapi/plugin_module.h" |
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
19 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 20 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
20 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
21 #include "webkit/plugins/ppapi/resource_helper.h" | 22 #include "webkit/plugins/ppapi/resource_helper.h" |
22 #include "webkit/plugins/ppapi/resource_tracker.h" | 23 #include "webkit/plugins/ppapi/resource_tracker.h" |
23 | 24 |
| 25 using ::ppapi::PpapiGlobals; |
24 using ::ppapi::thunk::EnterResourceNoLock; | 26 using ::ppapi::thunk::EnterResourceNoLock; |
25 using ::ppapi::thunk::PPB_DirectoryReader_API; | 27 using ::ppapi::thunk::PPB_DirectoryReader_API; |
26 using ::ppapi::thunk::PPB_FileRef_API; | 28 using ::ppapi::thunk::PPB_FileRef_API; |
27 | 29 |
28 namespace webkit { | 30 namespace webkit { |
29 namespace ppapi { | 31 namespace ppapi { |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 std::string FilePathStringToUTF8String(const FilePath::StringType& str) { | 35 std::string FilePathStringToUTF8String(const FilePath::StringType& str) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 123 |
122 FillUpEntry(); | 124 FillUpEntry(); |
123 entry_ = NULL; | 125 entry_ = NULL; |
124 } | 126 } |
125 | 127 |
126 bool PPB_DirectoryReader_Impl::FillUpEntry() { | 128 bool PPB_DirectoryReader_Impl::FillUpEntry() { |
127 DCHECK(entry_); | 129 DCHECK(entry_); |
128 if (!entries_.empty()) { | 130 if (!entries_.empty()) { |
129 base::FileUtilProxy::Entry dir_entry = entries_.front(); | 131 base::FileUtilProxy::Entry dir_entry = entries_.front(); |
130 entries_.pop(); | 132 entries_.pop(); |
131 if (entry_->file_ref) | 133 if (entry_->file_ref) { |
132 ResourceTracker::Get()->ReleaseResource(entry_->file_ref); | 134 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( |
| 135 entry_->file_ref); |
| 136 } |
133 | 137 |
134 PPB_FileRef_Impl* file_ref = PPB_FileRef_Impl::CreateInternal( | 138 PPB_FileRef_Impl* file_ref = PPB_FileRef_Impl::CreateInternal( |
135 directory_ref_->file_system()->pp_resource(), | 139 directory_ref_->file_system()->pp_resource(), |
136 FilePathStringToUTF8String(dir_entry.name)); | 140 FilePathStringToUTF8String(dir_entry.name)); |
137 if (!file_ref) | 141 if (!file_ref) |
138 return false; | 142 return false; |
139 entry_->file_ref = file_ref->GetReference(); | 143 entry_->file_ref = file_ref->GetReference(); |
140 entry_->file_type = | 144 entry_->file_type = |
141 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); | 145 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); |
142 return true; | 146 return true; |
143 } | 147 } |
144 | 148 |
145 if (!has_more_) { | 149 if (!has_more_) { |
146 entry_->file_ref = 0; | 150 entry_->file_ref = 0; |
147 return true; | 151 return true; |
148 } | 152 } |
149 | 153 |
150 return false; | 154 return false; |
151 } | 155 } |
152 | 156 |
153 } // namespace ppapi | 157 } // namespace ppapi |
154 } // namespace webkit | 158 } // namespace webkit |
OLD | NEW |