| 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/get_metadata.h
" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "chrome/common/extensions/api/file_system_provider.h" | 14 #include "chrome/common/extensions/api/file_system_provider.h" |
| 14 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 15 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 namespace file_system_provider { | 18 namespace file_system_provider { |
| 18 namespace operations { | 19 namespace operations { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Convert |value| into |output|. If parsing fails, then returns false. | 22 // Convert |value| into |output|. If parsing fails, then returns false. |
| 22 bool ConvertRequestValueToFileInfo(scoped_ptr<RequestValue> value, | 23 bool ConvertRequestValueToFileInfo(std::unique_ptr<RequestValue> value, |
| 23 int fields, | 24 int fields, |
| 24 bool root_entry, | 25 bool root_entry, |
| 25 EntryMetadata* output) { | 26 EntryMetadata* output) { |
| 26 using extensions::api::file_system_provider::EntryMetadata; | 27 using extensions::api::file_system_provider::EntryMetadata; |
| 27 using extensions::api::file_system_provider_internal:: | 28 using extensions::api::file_system_provider_internal:: |
| 28 GetMetadataRequestedSuccess::Params; | 29 GetMetadataRequestedSuccess::Params; |
| 29 | 30 |
| 30 const Params* params = value->get_metadata_success_params(); | 31 const Params* params = value->get_metadata_success_params(); |
| 31 if (!params) | 32 if (!params) |
| 32 return false; | 33 return false; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 168 |
| 168 return SendEvent( | 169 return SendEvent( |
| 169 request_id, | 170 request_id, |
| 170 extensions::events::FILE_SYSTEM_PROVIDER_ON_GET_METADATA_REQUESTED, | 171 extensions::events::FILE_SYSTEM_PROVIDER_ON_GET_METADATA_REQUESTED, |
| 171 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, | 172 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, |
| 172 extensions::api::file_system_provider::OnGetMetadataRequested::Create( | 173 extensions::api::file_system_provider::OnGetMetadataRequested::Create( |
| 173 options)); | 174 options)); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void GetMetadata::OnSuccess(int /* request_id */, | 177 void GetMetadata::OnSuccess(int /* request_id */, |
| 177 scoped_ptr<RequestValue> result, | 178 std::unique_ptr<RequestValue> result, |
| 178 bool has_more) { | 179 bool has_more) { |
| 179 scoped_ptr<EntryMetadata> metadata(new EntryMetadata); | 180 std::unique_ptr<EntryMetadata> metadata(new EntryMetadata); |
| 180 const bool convert_result = ConvertRequestValueToFileInfo( | 181 const bool convert_result = ConvertRequestValueToFileInfo( |
| 181 std::move(result), fields_, | 182 std::move(result), fields_, |
| 182 entry_path_.AsUTF8Unsafe() == FILE_PATH_LITERAL("/"), metadata.get()); | 183 entry_path_.AsUTF8Unsafe() == FILE_PATH_LITERAL("/"), metadata.get()); |
| 183 | 184 |
| 184 if (!convert_result) { | 185 if (!convert_result) { |
| 185 LOG(ERROR) << "Failed to parse a response for the get metadata operation."; | 186 LOG(ERROR) << "Failed to parse a response for the get metadata operation."; |
| 186 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), | 187 callback_.Run(base::WrapUnique<EntryMetadata>(NULL), |
| 187 base::File::FILE_ERROR_IO); | 188 base::File::FILE_ERROR_IO); |
| 188 return; | 189 return; |
| 189 } | 190 } |
| 190 | 191 |
| 191 callback_.Run(std::move(metadata), base::File::FILE_OK); | 192 callback_.Run(std::move(metadata), base::File::FILE_OK); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void GetMetadata::OnError(int /* request_id */, | 195 void GetMetadata::OnError(int /* request_id */, |
| 195 scoped_ptr<RequestValue> /* result */, | 196 std::unique_ptr<RequestValue> /* result */, |
| 196 base::File::Error error) { | 197 base::File::Error error) { |
| 197 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), error); | 198 callback_.Run(base::WrapUnique<EntryMetadata>(NULL), error); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace operations | 201 } // namespace operations |
| 201 } // namespace file_system_provider | 202 } // namespace file_system_provider |
| 202 } // namespace chromeos | 203 } // namespace chromeos |
| OLD | NEW |