| 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/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 local_file_service_->ProcessLocalChange( | 369 local_file_service_->ProcessLocalChange( |
| 370 remote_file_service_->GetLocalChangeProcessor(), | 370 remote_file_service_->GetLocalChangeProcessor(), |
| 371 base::Bind(&SyncFileSystemService::DidProcessLocalChange, | 371 base::Bind(&SyncFileSystemService::DidProcessLocalChange, |
| 372 AsWeakPtr())); | 372 AsWeakPtr())); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void SyncFileSystemService::DidProcessRemoteChange( | 375 void SyncFileSystemService::DidProcessRemoteChange( |
| 376 fileapi::SyncStatusCode status, | 376 fileapi::SyncStatusCode status, |
| 377 const FileSystemURL& url, | 377 const FileSystemURL& url, |
| 378 fileapi::SyncOperationType type) { | 378 fileapi::SyncOperationType type) { |
| 379 DVLOG(1) << "DidProcessRemoteChange: " | 379 DVLOG(1) << "DidProcessRemoteChange:" |
| 380 << " status=" << status | 380 << " status=" << status |
| 381 << " (" << SyncStatusCodeToString(status) << ")" |
| 381 << " url=" << url.DebugString() | 382 << " url=" << url.DebugString() |
| 382 << " operation_type=" << type; | 383 << " operation_type=" << type; |
| 383 DCHECK(remote_sync_running_); | 384 DCHECK(remote_sync_running_); |
| 384 remote_sync_running_ = false; | 385 remote_sync_running_ = false; |
| 385 if (status == fileapi::SYNC_STATUS_OK && | 386 if (status == fileapi::SYNC_STATUS_OK && |
| 386 type != fileapi::SYNC_OPERATION_NONE) { | 387 type != fileapi::SYNC_OPERATION_NONE) { |
| 387 // Notify observers of the changes made for a remote sync. | 388 // Notify observers of the changes made for a remote sync. |
| 388 FOR_EACH_OBSERVER(SyncEventObserver, observers_, OnFileSynced(url, type)); | 389 FOR_EACH_OBSERVER(SyncEventObserver, observers_, OnFileSynced(url, type)); |
| 389 } else if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { | 390 } else if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { |
| 390 // We seem to have no changes to work on for now. | 391 // We seem to have no changes to work on for now. |
| 391 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. | 392 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. |
| 392 return; | 393 return; |
| 393 } else if (status == fileapi::SYNC_STATUS_FILE_BUSY) { | 394 } else if (status == fileapi::SYNC_STATUS_FILE_BUSY) { |
| 394 is_waiting_remote_sync_enabled_ = true; | 395 is_waiting_remote_sync_enabled_ = true; |
| 395 local_file_service_->RegisterURLForWaitingSync( | 396 local_file_service_->RegisterURLForWaitingSync( |
| 396 url, base::Bind(&SyncFileSystemService::OnSyncEnabledForRemoteSync, | 397 url, base::Bind(&SyncFileSystemService::OnSyncEnabledForRemoteSync, |
| 397 AsWeakPtr())); | 398 AsWeakPtr())); |
| 398 return; | 399 return; |
| 399 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { | 400 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { |
| 400 // TODO(kinuko,tzik): Handle conflict! | 401 // TODO(kinuko,tzik): Handle conflict! |
| 401 } | 402 } |
| 402 base::MessageLoopProxy::current()->PostTask( | 403 base::MessageLoopProxy::current()->PostTask( |
| 403 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, | 404 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, |
| 404 AsWeakPtr())); | 405 AsWeakPtr())); |
| 405 } | 406 } |
| 406 | 407 |
| 407 void SyncFileSystemService::DidProcessLocalChange( | 408 void SyncFileSystemService::DidProcessLocalChange( |
| 408 fileapi::SyncStatusCode status, const FileSystemURL& url) { | 409 fileapi::SyncStatusCode status, const FileSystemURL& url) { |
| 409 DVLOG(1) << "DidProcessLocalChange: " | 410 DVLOG(1) << "DidProcessLocalChange " |
| 410 << " status=" << status | 411 << " status=" << status |
| 412 << " (" << SyncStatusCodeToString(status) << ")" |
| 411 << " url=" << url.DebugString(); | 413 << " url=" << url.DebugString(); |
| 412 DCHECK(local_sync_running_); | 414 DCHECK(local_sync_running_); |
| 413 local_sync_running_ = false; | 415 local_sync_running_ = false; |
| 414 if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { | 416 if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { |
| 415 // We seem to have no changes to work on for now. | 417 // We seem to have no changes to work on for now. |
| 416 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. | 418 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. |
| 417 return; | 419 return; |
| 418 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { | 420 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { |
| 419 // TODO(kinuko,tzik): Handle conflict! | 421 // TODO(kinuko,tzik): Handle conflict! |
| 420 } | 422 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 remote_file_service = mock_remote_file_service_.Pass(); | 521 remote_file_service = mock_remote_file_service_.Pass(); |
| 520 else | 522 else |
| 521 remote_file_service.reset(new DriveFileSyncService(profile)); | 523 remote_file_service.reset(new DriveFileSyncService(profile)); |
| 522 | 524 |
| 523 service->Initialize(local_file_service.Pass(), | 525 service->Initialize(local_file_service.Pass(), |
| 524 remote_file_service.Pass()); | 526 remote_file_service.Pass()); |
| 525 return service; | 527 return service; |
| 526 } | 528 } |
| 527 | 529 |
| 528 } // namespace sync_file_system | 530 } // namespace sync_file_system |
| OLD | NEW |