| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync_file_system/local/local_file_change_tracker.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 base::File::Info file_info; | 344 base::File::Info file_info; |
| 345 base::FilePath platform_path; | 345 base::FilePath platform_path; |
| 346 | 346 |
| 347 while (!dirty_files.empty()) { | 347 while (!dirty_files.empty()) { |
| 348 const FileSystemURL url = dirty_files.front(); | 348 const FileSystemURL url = dirty_files.front(); |
| 349 dirty_files.pop(); | 349 dirty_files.pop(); |
| 350 DCHECK_EQ(url.type(), fileapi::kFileSystemTypeSyncable); | 350 DCHECK_EQ(url.type(), fileapi::kFileSystemTypeSyncable); |
| 351 | 351 |
| 352 switch (file_util->GetFileInfo(context.get(), url, | 352 switch (file_util->GetFileInfo(context.get(), url, |
| 353 &file_info, &platform_path)) { | 353 &file_info, &platform_path)) { |
| 354 case base::PLATFORM_FILE_OK: { | 354 case base::File::FILE_OK: { |
| 355 if (!file_info.is_directory) { | 355 if (!file_info.is_directory) { |
| 356 RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 356 RecordChange(url, FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 357 SYNC_FILE_TYPE_FILE)); | 357 SYNC_FILE_TYPE_FILE)); |
| 358 break; | 358 break; |
| 359 } | 359 } |
| 360 | 360 |
| 361 RecordChange(url, FileChange( | 361 RecordChange(url, FileChange( |
| 362 FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 362 FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
| 363 SYNC_FILE_TYPE_DIRECTORY)); | 363 SYNC_FILE_TYPE_DIRECTORY)); |
| 364 | 364 |
| 365 // Push files and directories in this directory into |dirty_files|. | 365 // Push files and directories in this directory into |dirty_files|. |
| 366 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( | 366 scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( |
| 367 file_util->CreateFileEnumerator(context.get(), url)); | 367 file_util->CreateFileEnumerator(context.get(), url)); |
| 368 base::FilePath path_each; | 368 base::FilePath path_each; |
| 369 while (!(path_each = enumerator->Next()).empty()) { | 369 while (!(path_each = enumerator->Next()).empty()) { |
| 370 dirty_files.push(CreateSyncableFileSystemURL( | 370 dirty_files.push(CreateSyncableFileSystemURL( |
| 371 url.origin(), path_each)); | 371 url.origin(), path_each)); |
| 372 } | 372 } |
| 373 break; | 373 break; |
| 374 } | 374 } |
| 375 case base::PLATFORM_FILE_ERROR_NOT_FOUND: { | 375 case base::File::FILE_ERROR_NOT_FOUND: { |
| 376 // File represented by |url| has already been deleted. Since we cannot | 376 // File represented by |url| has already been deleted. Since we cannot |
| 377 // figure out if this file was directory or not from the URL, file | 377 // figure out if this file was directory or not from the URL, file |
| 378 // type is treated as SYNC_FILE_TYPE_UNKNOWN. | 378 // type is treated as SYNC_FILE_TYPE_UNKNOWN. |
| 379 // | 379 // |
| 380 // NOTE: Directory to have been reverted (that is, ADD -> DELETE) is | 380 // NOTE: Directory to have been reverted (that is, ADD -> DELETE) is |
| 381 // also treated as FILE_CHANGE_DELETE. | 381 // also treated as FILE_CHANGE_DELETE. |
| 382 RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, | 382 RecordChange(url, FileChange(FileChange::FILE_CHANGE_DELETE, |
| 383 SYNC_FILE_TYPE_UNKNOWN)); | 383 SYNC_FILE_TYPE_UNKNOWN)); |
| 384 break; | 384 break; |
| 385 } | 385 } |
| 386 case base::PLATFORM_FILE_ERROR_FAILED: | 386 case base::File::FILE_ERROR_FAILED: |
| 387 default: | 387 default: |
| 388 // TODO(nhiroki): handle file access error (http://crbug.com/155251). | 388 // TODO(nhiroki): handle file access error (http://crbug.com/155251). |
| 389 LOG(WARNING) << "Failed to access local file."; | 389 LOG(WARNING) << "Failed to access local file."; |
| 390 break; | 390 break; |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 return SYNC_STATUS_OK; | 393 return SYNC_STATUS_OK; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void LocalFileChangeTracker::RecordChange( | 396 void LocalFileChangeTracker::RecordChange( |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (!status.ok() && !status.IsNotFound()) { | 573 if (!status.ok() && !status.IsNotFound()) { |
| 574 HandleError(FROM_HERE, status); | 574 HandleError(FROM_HERE, status); |
| 575 db_status_ = LevelDBStatusToSyncStatusCode(status); | 575 db_status_ = LevelDBStatusToSyncStatusCode(status); |
| 576 db_.reset(); | 576 db_.reset(); |
| 577 return db_status_; | 577 return db_status_; |
| 578 } | 578 } |
| 579 return SYNC_STATUS_OK; | 579 return SYNC_STATUS_OK; |
| 580 } | 580 } |
| 581 | 581 |
| 582 } // namespace sync_file_system | 582 } // namespace sync_file_system |
| OLD | NEW |