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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // This is the only supported cloud backend service for now. | 37 // This is the only supported cloud backend service for now. |
38 const char* const kDriveCloudService = | 38 const char* const kDriveCloudService = |
39 sync_file_system::DriveFileSyncService::kServiceName; | 39 sync_file_system::DriveFileSyncService::kServiceName; |
40 | 40 |
41 // Error messages. | 41 // Error messages. |
42 const char kFileError[] = "File error %d."; | 42 const char kFileError[] = "File error %d."; |
43 const char kQuotaError[] = "Quota error %d."; | 43 const char kQuotaError[] = "Quota error %d."; |
44 | 44 |
45 api::sync_file_system::FileStatus FileSyncStatusEnumToExtensionEnum( | 45 api::sync_file_system::FileStatus FileSyncStatusEnumToExtensionEnum( |
46 const fileapi::SyncFileStatus state) { | 46 const sync_file_system::SyncFileStatus state) { |
47 switch (state) { | 47 switch (state) { |
48 case fileapi::SYNC_FILE_STATUS_UNKNOWN: | 48 case sync_file_system::SYNC_FILE_STATUS_UNKNOWN: |
49 return api::sync_file_system::FILE_STATUS_NONE; | 49 return api::sync_file_system::FILE_STATUS_NONE; |
50 case fileapi::SYNC_FILE_STATUS_SYNCED: | 50 case sync_file_system::SYNC_FILE_STATUS_SYNCED: |
51 return api::sync_file_system::FILE_STATUS_SYNCED; | 51 return api::sync_file_system::FILE_STATUS_SYNCED; |
52 case fileapi::SYNC_FILE_STATUS_HAS_PENDING_CHANGES: | 52 case sync_file_system::SYNC_FILE_STATUS_HAS_PENDING_CHANGES: |
53 return api::sync_file_system::FILE_STATUS_PENDING; | 53 return api::sync_file_system::FILE_STATUS_PENDING; |
54 case fileapi::SYNC_FILE_STATUS_CONFLICTING: | 54 case sync_file_system::SYNC_FILE_STATUS_CONFLICTING: |
55 return api::sync_file_system:: | 55 return api::sync_file_system::FILE_STATUS_CONFLICTING; |
56 FILE_STATUS_CONFLICTING; | |
57 } | 56 } |
58 NOTREACHED(); | 57 NOTREACHED(); |
59 return api::sync_file_system::FILE_STATUS_NONE; | 58 return api::sync_file_system::FILE_STATUS_NONE; |
60 } | 59 } |
61 | 60 |
62 sync_file_system::SyncFileSystemService* GetSyncFileSystemService( | 61 sync_file_system::SyncFileSystemService* GetSyncFileSystemService( |
63 Profile* profile) { | 62 Profile* profile) { |
64 sync_file_system::SyncFileSystemService* service = | 63 sync_file_system::SyncFileSystemService* service = |
65 SyncFileSystemServiceFactory::GetForProfile(profile); | 64 SyncFileSystemServiceFactory::GetForProfile(profile); |
66 DCHECK(service); | 65 DCHECK(service); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 236 |
238 SyncFileSystemServiceFactory::GetForProfile(profile())->GetFileSyncStatus( | 237 SyncFileSystemServiceFactory::GetForProfile(profile())->GetFileSyncStatus( |
239 file_system_url, | 238 file_system_url, |
240 Bind(&SyncFileSystemGetFileStatusFunction::DidGetFileStatus, | 239 Bind(&SyncFileSystemGetFileStatusFunction::DidGetFileStatus, |
241 this)); | 240 this)); |
242 return true; | 241 return true; |
243 } | 242 } |
244 | 243 |
245 void SyncFileSystemGetFileStatusFunction::DidGetFileStatus( | 244 void SyncFileSystemGetFileStatusFunction::DidGetFileStatus( |
246 const fileapi::SyncStatusCode sync_service_status, | 245 const fileapi::SyncStatusCode sync_service_status, |
247 const fileapi::SyncFileStatus sync_file_status) { | 246 const sync_file_system::SyncFileStatus sync_file_status) { |
248 // Repost to switch from IO thread to UI thread for SendResponse(). | 247 // Repost to switch from IO thread to UI thread for SendResponse(). |
249 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 248 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
251 BrowserThread::PostTask( | 250 BrowserThread::PostTask( |
252 BrowserThread::UI, | 251 BrowserThread::UI, |
253 FROM_HERE, | 252 FROM_HERE, |
254 Bind(&SyncFileSystemGetFileStatusFunction::DidGetFileStatus, | 253 Bind(&SyncFileSystemGetFileStatusFunction::DidGetFileStatus, |
255 this, sync_service_status, sync_file_status)); | 254 this, sync_service_status, sync_file_status)); |
256 return; | 255 return; |
257 } | 256 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 289 } |
291 | 290 |
292 api::sync_file_system::StorageInfo info; | 291 api::sync_file_system::StorageInfo info; |
293 info.usage_bytes = usage; | 292 info.usage_bytes = usage; |
294 info.quota_bytes = quota; | 293 info.quota_bytes = quota; |
295 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info); | 294 results_ = api::sync_file_system::GetUsageAndQuota::Results::Create(info); |
296 SendResponse(true); | 295 SendResponse(true); |
297 } | 296 } |
298 | 297 |
299 } // namespace extensions | 298 } // namespace extensions |
OLD | NEW |