| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/operations/read_directory
.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/read_directory
.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/memory/linked_ptr.h" | |
| 13 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" | 12 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
| 14 #include "chrome/common/extensions/api/file_system_provider.h" | 13 #include "chrome/common/extensions/api/file_system_provider.h" |
| 15 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 14 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| 16 | 15 |
| 17 namespace chromeos { | 16 namespace chromeos { |
| 18 namespace file_system_provider { | 17 namespace file_system_provider { |
| 19 namespace operations { | 18 namespace operations { |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| 22 // Convert |input| into |output|. If parsing fails, then returns false. | 21 // Convert |input| into |output|. If parsing fails, then returns false. |
| 23 bool ConvertRequestValueToEntryList(scoped_ptr<RequestValue> value, | 22 bool ConvertRequestValueToEntryList(scoped_ptr<RequestValue> value, |
| 24 storage::AsyncFileUtil::EntryList* output) { | 23 storage::AsyncFileUtil::EntryList* output) { |
| 25 using extensions::api::file_system_provider::EntryMetadata; | 24 using extensions::api::file_system_provider::EntryMetadata; |
| 26 using extensions::api::file_system_provider_internal:: | 25 using extensions::api::file_system_provider_internal:: |
| 27 ReadDirectoryRequestedSuccess::Params; | 26 ReadDirectoryRequestedSuccess::Params; |
| 28 | 27 |
| 29 const Params* params = value->read_directory_success_params(); | 28 const Params* params = value->read_directory_success_params(); |
| 30 if (!params) | 29 if (!params) |
| 31 return false; | 30 return false; |
| 32 | 31 |
| 33 for (size_t i = 0; i < params->entries.size(); ++i) { | 32 for (const EntryMetadata& entry_metadata : params->entries) { |
| 34 const linked_ptr<EntryMetadata> entry_metadata = params->entries[i]; | |
| 35 if (!ValidateIDLEntryMetadata( | 33 if (!ValidateIDLEntryMetadata( |
| 36 *entry_metadata, | 34 entry_metadata, |
| 37 ProvidedFileSystemInterface::METADATA_FIELD_IS_DIRECTORY | | 35 ProvidedFileSystemInterface::METADATA_FIELD_IS_DIRECTORY | |
| 38 ProvidedFileSystemInterface::METADATA_FIELD_NAME, | 36 ProvidedFileSystemInterface::METADATA_FIELD_NAME, |
| 39 false /* root_entry */)) { | 37 false /* root_entry */)) { |
| 40 return false; | 38 return false; |
| 41 } | 39 } |
| 42 | 40 |
| 43 storage::DirectoryEntry output_entry; | 41 storage::DirectoryEntry output_entry; |
| 44 output_entry.is_directory = *entry_metadata->is_directory; | 42 output_entry.is_directory = *entry_metadata.is_directory; |
| 45 output_entry.name = *entry_metadata->name; | 43 output_entry.name = *entry_metadata.name; |
| 46 | 44 |
| 47 output->push_back(output_entry); | 45 output->push_back(output_entry); |
| 48 } | 46 } |
| 49 | 47 |
| 50 return true; | 48 return true; |
| 51 } | 49 } |
| 52 | 50 |
| 53 } // namespace | 51 } // namespace |
| 54 | 52 |
| 55 ReadDirectory::ReadDirectory( | 53 ReadDirectory::ReadDirectory( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 void ReadDirectory::OnError(int /* request_id */, | 106 void ReadDirectory::OnError(int /* request_id */, |
| 109 scoped_ptr<RequestValue> /* result */, | 107 scoped_ptr<RequestValue> /* result */, |
| 110 base::File::Error error) { | 108 base::File::Error error) { |
| 111 callback_.Run( | 109 callback_.Run( |
| 112 error, storage::AsyncFileUtil::EntryList(), false /* has_more */); | 110 error, storage::AsyncFileUtil::EntryList(), false /* has_more */); |
| 113 } | 111 } |
| 114 | 112 |
| 115 } // namespace operations | 113 } // namespace operations |
| 116 } // namespace file_system_provider | 114 } // namespace file_system_provider |
| 117 } // namespace chromeos | 115 } // namespace chromeos |
| OLD | NEW |