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 "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h" | 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (num_results_received_ < num_expected_results_) | 268 if (num_results_received_ < num_expected_results_) |
269 return; | 269 return; |
270 | 270 |
271 // All results received. Dump array of statuses into extension enum values. | 271 // All results received. Dump array of statuses into extension enum values. |
272 // Note that the enum types need to be set as strings manually as the | 272 // Note that the enum types need to be set as strings manually as the |
273 // autogenerated Results::Create function thinks the enum values should be | 273 // autogenerated Results::Create function thinks the enum values should be |
274 // returned as int values. | 274 // returned as int values. |
275 std::unique_ptr<base::ListValue> status_array(new base::ListValue()); | 275 std::unique_ptr<base::ListValue> status_array(new base::ListValue()); |
276 for (URLToStatusMap::iterator it = file_sync_statuses_.begin(); | 276 for (URLToStatusMap::iterator it = file_sync_statuses_.begin(); |
277 it != file_sync_statuses_.end(); ++it) { | 277 it != file_sync_statuses_.end(); ++it) { |
278 base::DictionaryValue* dict = new base::DictionaryValue(); | 278 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
279 status_array->Append(dict); | |
280 | 279 |
281 storage::FileSystemURL url = it->first; | 280 storage::FileSystemURL url = it->first; |
282 SyncStatusCode file_error = it->second.first; | 281 SyncStatusCode file_error = it->second.first; |
283 api::sync_file_system::FileStatus file_status = | 282 api::sync_file_system::FileStatus file_status = |
284 SyncFileStatusToExtensionEnum(it->second.second); | 283 SyncFileStatusToExtensionEnum(it->second.second); |
285 | 284 |
286 dict->Set("entry", CreateDictionaryValueForFileSystemEntry( | 285 dict->Set("entry", CreateDictionaryValueForFileSystemEntry( |
287 url, sync_file_system::SYNC_FILE_TYPE_FILE)); | 286 url, sync_file_system::SYNC_FILE_TYPE_FILE)); |
288 dict->SetString("status", ToString(file_status)); | 287 dict->SetString("status", ToString(file_status)); |
289 | 288 |
290 if (file_error == sync_file_system::SYNC_STATUS_OK) | 289 if (file_error == sync_file_system::SYNC_STATUS_OK) |
291 continue; | 290 continue; |
292 dict->SetString("error", ErrorToString(file_error)); | 291 dict->SetString("error", ErrorToString(file_error)); |
| 292 |
| 293 status_array->Append(std::move(dict)); |
293 } | 294 } |
294 SetResult(std::move(status_array)); | 295 SetResult(std::move(status_array)); |
295 | 296 |
296 SendResponse(true); | 297 SendResponse(true); |
297 } | 298 } |
298 | 299 |
299 bool SyncFileSystemGetUsageAndQuotaFunction::RunAsync() { | 300 bool SyncFileSystemGetUsageAndQuotaFunction::RunAsync() { |
300 std::string url; | 301 std::string url; |
301 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 302 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
302 | 303 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 sync_file_system::SyncFileSystemService* service = | 378 sync_file_system::SyncFileSystemService* service = |
378 GetSyncFileSystemService(GetProfile()); | 379 GetSyncFileSystemService(GetProfile()); |
379 if (!service) | 380 if (!service) |
380 return false; | 381 return false; |
381 results_ = api::sync_file_system::GetServiceStatus::Results::Create( | 382 results_ = api::sync_file_system::GetServiceStatus::Results::Create( |
382 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); | 383 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); |
383 return true; | 384 return true; |
384 } | 385 } |
385 | 386 |
386 } // namespace extensions | 387 } // namespace extensions |
OLD | NEW |