| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "ppapi/cpp/dev/directory_entry_dev.h" | 5 #include "ppapi/cpp/directory_entry.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "ppapi/cpp/logging.h" | 9 #include "ppapi/cpp/logging.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 | 11 |
| 12 namespace pp { | 12 namespace pp { |
| 13 | 13 |
| 14 DirectoryEntry_Dev::DirectoryEntry_Dev() { | 14 DirectoryEntry::DirectoryEntry() { |
| 15 memset(&data_, 0, sizeof(data_)); | 15 memset(&data_, 0, sizeof(data_)); |
| 16 } | 16 } |
| 17 | 17 |
| 18 DirectoryEntry_Dev::DirectoryEntry_Dev( | 18 DirectoryEntry::DirectoryEntry( |
| 19 PassRef, const PP_DirectoryEntry_Dev& data) { | 19 PassRef, const PP_DirectoryEntry& data) { |
| 20 data_.file_ref = data.file_ref; | 20 data_.file_ref = data.file_ref; |
| 21 data_.file_type = data.file_type; | 21 data_.file_type = data.file_type; |
| 22 } | 22 } |
| 23 | 23 |
| 24 DirectoryEntry_Dev::DirectoryEntry_Dev(const DirectoryEntry_Dev& other) { | 24 DirectoryEntry::DirectoryEntry(const DirectoryEntry& other) { |
| 25 data_.file_ref = other.data_.file_ref; | 25 data_.file_ref = other.data_.file_ref; |
| 26 data_.file_type = other.data_.file_type; | 26 data_.file_type = other.data_.file_type; |
| 27 if (data_.file_ref) | 27 if (data_.file_ref) |
| 28 Module::Get()->core()->AddRefResource(data_.file_ref); | 28 Module::Get()->core()->AddRefResource(data_.file_ref); |
| 29 } | 29 } |
| 30 | 30 |
| 31 DirectoryEntry_Dev::~DirectoryEntry_Dev() { | 31 DirectoryEntry::~DirectoryEntry() { |
| 32 if (data_.file_ref) | 32 if (data_.file_ref) |
| 33 Module::Get()->core()->ReleaseResource(data_.file_ref); | 33 Module::Get()->core()->ReleaseResource(data_.file_ref); |
| 34 } | 34 } |
| 35 | 35 |
| 36 DirectoryEntry_Dev& DirectoryEntry_Dev::operator=( | 36 DirectoryEntry& DirectoryEntry::operator=( |
| 37 const DirectoryEntry_Dev& other) { | 37 const DirectoryEntry& other) { |
| 38 if (data_.file_ref) | 38 if (data_.file_ref) |
| 39 Module::Get()->core()->ReleaseResource(data_.file_ref); | 39 Module::Get()->core()->ReleaseResource(data_.file_ref); |
| 40 data_ = other.data_; | 40 data_ = other.data_; |
| 41 if (data_.file_ref) | 41 if (data_.file_ref) |
| 42 Module::Get()->core()->AddRefResource(data_.file_ref); | 42 Module::Get()->core()->AddRefResource(data_.file_ref); |
| 43 return *this; | 43 return *this; |
| 44 } | 44 } |
| 45 | 45 |
| 46 namespace internal { | 46 namespace internal { |
| 47 | 47 |
| 48 DirectoryEntryArrayOutputAdapterWithStorage:: | 48 DirectoryEntryArrayOutputAdapterWithStorage:: |
| 49 DirectoryEntryArrayOutputAdapterWithStorage() { | 49 DirectoryEntryArrayOutputAdapterWithStorage() { |
| 50 set_output(&temp_storage_); | 50 set_output(&temp_storage_); |
| 51 } | 51 } |
| 52 | 52 |
| 53 DirectoryEntryArrayOutputAdapterWithStorage:: | 53 DirectoryEntryArrayOutputAdapterWithStorage:: |
| 54 ~DirectoryEntryArrayOutputAdapterWithStorage() { | 54 ~DirectoryEntryArrayOutputAdapterWithStorage() { |
| 55 if (!temp_storage_.empty()) { | 55 if (!temp_storage_.empty()) { |
| 56 // An easy way to release the resource references held by |temp_storage_|. | 56 // An easy way to release the resource references held by |temp_storage_|. |
| 57 // A destructor for PP_DirectoryEntry_Dev will release them. | 57 // A destructor for PP_DirectoryEntry will release them. |
| 58 output(); | 58 output(); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::vector<DirectoryEntry_Dev>& | 62 std::vector<DirectoryEntry>& |
| 63 DirectoryEntryArrayOutputAdapterWithStorage::output() { | 63 DirectoryEntryArrayOutputAdapterWithStorage::output() { |
| 64 PP_DCHECK(output_storage_.empty()); | 64 PP_DCHECK(output_storage_.empty()); |
| 65 typedef std::vector<PP_DirectoryEntry_Dev> Entries; | 65 typedef std::vector<PP_DirectoryEntry> Entries; |
| 66 for (Entries::iterator it = temp_storage_.begin(); | 66 for (Entries::iterator it = temp_storage_.begin(); |
| 67 it != temp_storage_.end(); | 67 it != temp_storage_.end(); |
| 68 ++it) { | 68 ++it) { |
| 69 output_storage_.push_back(DirectoryEntry_Dev(PASS_REF, *it)); | 69 output_storage_.push_back(DirectoryEntry(PASS_REF, *it)); |
| 70 } | 70 } |
| 71 temp_storage_.clear(); | 71 temp_storage_.clear(); |
| 72 return output_storage_; | 72 return output_storage_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace internal | 75 } // namespace internal |
| 76 } // namespace pp | 76 } // namespace pp |
| OLD | NEW |