| OLD | NEW |
| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 using ::ppapi::TrackedCallback; | 26 using ::ppapi::TrackedCallback; |
| 27 using ::ppapi::thunk::EnterResourceNoLock; | 27 using ::ppapi::thunk::EnterResourceNoLock; |
| 28 using ::ppapi::thunk::PPB_DirectoryReader_API; | 28 using ::ppapi::thunk::PPB_DirectoryReader_API; |
| 29 using ::ppapi::thunk::PPB_FileRef_API; | 29 using ::ppapi::thunk::PPB_FileRef_API; |
| 30 | 30 |
| 31 namespace webkit { | 31 namespace webkit { |
| 32 namespace ppapi { | 32 namespace ppapi { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 std::string FilePathStringToUTF8String(const FilePath::StringType& str) { | 36 std::string FilePathStringToUTF8String(const base::FilePath::StringType& str) { |
| 37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 38 return WideToUTF8(str); | 38 return WideToUTF8(str); |
| 39 #elif defined(OS_POSIX) | 39 #elif defined(OS_POSIX) |
| 40 return str; | 40 return str; |
| 41 #else | 41 #else |
| 42 #error "Unsupported platform." | 42 #error "Unsupported platform." |
| 43 #endif | 43 #endif |
| 44 } | 44 } |
| 45 | 45 |
| 46 FilePath::StringType UTF8StringToFilePathString(const std::string& str) { | 46 base::FilePath::StringType UTF8StringToFilePathString(const std::string& str) { |
| 47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 return UTF8ToWide(str); | 48 return UTF8ToWide(str); |
| 49 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
| 50 return str; | 50 return str; |
| 51 #else | 51 #else |
| 52 #error "Unsupported platform." | 52 #error "Unsupported platform." |
| 53 #endif | 53 #endif |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 void PPB_DirectoryReader_Impl::AddNewEntries( | 105 void PPB_DirectoryReader_Impl::AddNewEntries( |
| 106 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { | 106 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { |
| 107 DCHECK(!entries.empty() || !has_more); | 107 DCHECK(!entries.empty() || !has_more); |
| 108 has_more_ = has_more; | 108 has_more_ = has_more; |
| 109 | 109 |
| 110 std::string dir_path = directory_ref_->GetCreateInfo().path; | 110 std::string dir_path = directory_ref_->GetCreateInfo().path; |
| 111 if (dir_path[dir_path.size() - 1] != '/') | 111 if (dir_path[dir_path.size() - 1] != '/') |
| 112 dir_path += '/'; | 112 dir_path += '/'; |
| 113 FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path); | 113 base::FilePath::StringType dir_file_path = UTF8StringToFilePathString(dir_path
); |
| 114 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it = | 114 for (std::vector<base::FileUtilProxy::Entry>::const_iterator it = |
| 115 entries.begin(); it != entries.end(); it++) { | 115 entries.begin(); it != entries.end(); it++) { |
| 116 base::FileUtilProxy::Entry entry; | 116 base::FileUtilProxy::Entry entry; |
| 117 entry.name = dir_file_path + it->name; | 117 entry.name = dir_file_path + it->name; |
| 118 entry.is_directory = it->is_directory; | 118 entry.is_directory = it->is_directory; |
| 119 entries_.push(entry); | 119 entries_.push(entry); |
| 120 } | 120 } |
| 121 | 121 |
| 122 FillUpEntry(); | 122 FillUpEntry(); |
| 123 entry_ = NULL; | 123 entry_ = NULL; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 147 if (!has_more_) { | 147 if (!has_more_) { |
| 148 entry_->file_ref = 0; | 148 entry_->file_ref = 0; |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 return false; | 152 return false; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace ppapi | 155 } // namespace ppapi |
| 156 } // namespace webkit | 156 } // namespace webkit |
| OLD | NEW |