| 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 "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" | 12 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
| 13 #include "chrome/common/extensions/api/file_system_provider.h" | 13 #include "chrome/common/extensions/api/file_system_provider.h" |
| 14 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 14 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 namespace file_system_provider { | 17 namespace file_system_provider { |
| 18 namespace operations { | 18 namespace operations { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Convert |input| into |output|. If parsing fails, then returns false. | 21 // Convert |input| into |output|. If parsing fails, then returns false. |
| 22 bool ConvertRequestValueToEntryList(scoped_ptr<RequestValue> value, | 22 bool ConvertRequestValueToEntryList(std::unique_ptr<RequestValue> value, |
| 23 storage::AsyncFileUtil::EntryList* output) { | 23 storage::AsyncFileUtil::EntryList* output) { |
| 24 using extensions::api::file_system_provider::EntryMetadata; | 24 using extensions::api::file_system_provider::EntryMetadata; |
| 25 using extensions::api::file_system_provider_internal:: | 25 using extensions::api::file_system_provider_internal:: |
| 26 ReadDirectoryRequestedSuccess::Params; | 26 ReadDirectoryRequestedSuccess::Params; |
| 27 | 27 |
| 28 const Params* params = value->read_directory_success_params(); | 28 const Params* params = value->read_directory_success_params(); |
| 29 if (!params) | 29 if (!params) |
| 30 return false; | 30 return false; |
| 31 | 31 |
| 32 for (const EntryMetadata& entry_metadata : params->entries) { | 32 for (const EntryMetadata& entry_metadata : params->entries) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return SendEvent( | 78 return SendEvent( |
| 79 request_id, | 79 request_id, |
| 80 extensions::events::FILE_SYSTEM_PROVIDER_ON_READ_DIRECTORY_REQUESTED, | 80 extensions::events::FILE_SYSTEM_PROVIDER_ON_READ_DIRECTORY_REQUESTED, |
| 81 extensions::api::file_system_provider::OnReadDirectoryRequested:: | 81 extensions::api::file_system_provider::OnReadDirectoryRequested:: |
| 82 kEventName, | 82 kEventName, |
| 83 extensions::api::file_system_provider::OnReadDirectoryRequested::Create( | 83 extensions::api::file_system_provider::OnReadDirectoryRequested::Create( |
| 84 options)); | 84 options)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ReadDirectory::OnSuccess(int /* request_id */, | 87 void ReadDirectory::OnSuccess(int /* request_id */, |
| 88 scoped_ptr<RequestValue> result, | 88 std::unique_ptr<RequestValue> result, |
| 89 bool has_more) { | 89 bool has_more) { |
| 90 storage::AsyncFileUtil::EntryList entry_list; | 90 storage::AsyncFileUtil::EntryList entry_list; |
| 91 const bool convert_result = | 91 const bool convert_result = |
| 92 ConvertRequestValueToEntryList(std::move(result), &entry_list); | 92 ConvertRequestValueToEntryList(std::move(result), &entry_list); |
| 93 | 93 |
| 94 if (!convert_result) { | 94 if (!convert_result) { |
| 95 LOG(ERROR) | 95 LOG(ERROR) |
| 96 << "Failed to parse a response for the read directory operation."; | 96 << "Failed to parse a response for the read directory operation."; |
| 97 callback_.Run(base::File::FILE_ERROR_IO, | 97 callback_.Run(base::File::FILE_ERROR_IO, |
| 98 storage::AsyncFileUtil::EntryList(), | 98 storage::AsyncFileUtil::EntryList(), |
| 99 false /* has_more */); | 99 false /* has_more */); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 | 102 |
| 103 callback_.Run(base::File::FILE_OK, entry_list, has_more); | 103 callback_.Run(base::File::FILE_OK, entry_list, has_more); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ReadDirectory::OnError(int /* request_id */, | 106 void ReadDirectory::OnError(int /* request_id */, |
| 107 scoped_ptr<RequestValue> /* result */, | 107 std::unique_ptr<RequestValue> /* result */, |
| 108 base::File::Error error) { | 108 base::File::Error error) { |
| 109 callback_.Run( | 109 callback_.Run( |
| 110 error, storage::AsyncFileUtil::EntryList(), false /* has_more */); | 110 error, storage::AsyncFileUtil::EntryList(), false /* has_more */); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace operations | 113 } // namespace operations |
| 114 } // namespace file_system_provider | 114 } // namespace file_system_provider |
| 115 } // namespace chromeos | 115 } // namespace chromeos |
| OLD | NEW |