| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 return; | 333 return; |
| 334 } | 334 } |
| 335 | 335 |
| 336 api::sync_file_system::StorageInfo info; | 336 api::sync_file_system::StorageInfo info; |
| 337 info.usage_bytes = usage; | 337 info.usage_bytes = usage; |
| 338 info.quota_bytes = quota; | 338 info.quota_bytes = quota; |
| 339 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info); | 339 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info); |
| 340 SendResponse(true); | 340 SendResponse(true); |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool SyncFileSystemSetConflictResolutionPolicyFunction::RunImpl() { | 343 bool SyncFileSystemSetConflictResolutionPolicyFunction::RunSync() { |
| 344 std::string policy_string; | 344 std::string policy_string; |
| 345 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &policy_string)); | 345 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &policy_string)); |
| 346 ConflictResolutionPolicy policy = ExtensionEnumToConflictResolutionPolicy( | 346 ConflictResolutionPolicy policy = ExtensionEnumToConflictResolutionPolicy( |
| 347 api::sync_file_system::ParseConflictResolutionPolicy(policy_string)); | 347 api::sync_file_system::ParseConflictResolutionPolicy(policy_string)); |
| 348 if (policy == sync_file_system::CONFLICT_RESOLUTION_POLICY_UNKNOWN) { | 348 if (policy == sync_file_system::CONFLICT_RESOLUTION_POLICY_UNKNOWN) { |
| 349 SetError(base::StringPrintf(kUnsupportedConflictResolutionPolicy, | 349 SetError(base::StringPrintf(kUnsupportedConflictResolutionPolicy, |
| 350 policy_string.c_str())); | 350 policy_string.c_str())); |
| 351 return false; | 351 return false; |
| 352 } | 352 } |
| 353 sync_file_system::SyncFileSystemService* service = | 353 sync_file_system::SyncFileSystemService* service = |
| 354 GetSyncFileSystemService(GetProfile()); | 354 GetSyncFileSystemService(GetProfile()); |
| 355 DCHECK(service); | 355 DCHECK(service); |
| 356 SyncStatusCode status = service->SetConflictResolutionPolicy( | 356 SyncStatusCode status = service->SetConflictResolutionPolicy( |
| 357 source_url().GetOrigin(), policy); | 357 source_url().GetOrigin(), policy); |
| 358 if (status != sync_file_system::SYNC_STATUS_OK) { | 358 if (status != sync_file_system::SYNC_STATUS_OK) { |
| 359 SetError(ErrorToString(status)); | 359 SetError(ErrorToString(status)); |
| 360 return false; | 360 return false; |
| 361 } | 361 } |
| 362 return true; | 362 return true; |
| 363 } | 363 } |
| 364 | 364 |
| 365 bool SyncFileSystemGetConflictResolutionPolicyFunction::RunImpl() { | 365 bool SyncFileSystemGetConflictResolutionPolicyFunction::RunSync() { |
| 366 sync_file_system::SyncFileSystemService* service = | 366 sync_file_system::SyncFileSystemService* service = |
| 367 GetSyncFileSystemService(GetProfile()); | 367 GetSyncFileSystemService(GetProfile()); |
| 368 DCHECK(service); | 368 DCHECK(service); |
| 369 api::sync_file_system::ConflictResolutionPolicy policy = | 369 api::sync_file_system::ConflictResolutionPolicy policy = |
| 370 ConflictResolutionPolicyToExtensionEnum( | 370 ConflictResolutionPolicyToExtensionEnum( |
| 371 service->GetConflictResolutionPolicy(source_url().GetOrigin())); | 371 service->GetConflictResolutionPolicy(source_url().GetOrigin())); |
| 372 SetResult(new base::StringValue( | 372 SetResult(new base::StringValue( |
| 373 api::sync_file_system::ToString(policy))); | 373 api::sync_file_system::ToString(policy))); |
| 374 return true; | 374 return true; |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool SyncFileSystemGetServiceStatusFunction::RunImpl() { | 377 bool SyncFileSystemGetServiceStatusFunction::RunSync() { |
| 378 sync_file_system::SyncFileSystemService* service = | 378 sync_file_system::SyncFileSystemService* service = |
| 379 GetSyncFileSystemService(GetProfile()); | 379 GetSyncFileSystemService(GetProfile()); |
| 380 results_ = api::sync_file_system::GetServiceStatus::Results::Create( | 380 results_ = api::sync_file_system::GetServiceStatus::Results::Create( |
| 381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); | 381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); |
| 382 return true; | 382 return true; |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace extensions | 385 } // namespace extensions |
| OLD | NEW |