| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 << " status=" << status | 380 << " status=" << status |
| 381 << " url=" << url.DebugString() | 381 << " url=" << url.DebugString() |
| 382 << " operation_type=" << type; | 382 << " operation_type=" << type; |
| 383 DCHECK(remote_sync_running_); | 383 DCHECK(remote_sync_running_); |
| 384 remote_sync_running_ = false; | 384 remote_sync_running_ = false; |
| 385 if (status == fileapi::SYNC_STATUS_OK && | 385 if (status == fileapi::SYNC_STATUS_OK && |
| 386 type != fileapi::SYNC_OPERATION_NONE) { | 386 type != fileapi::SYNC_OPERATION_NONE) { |
| 387 // Notify observers of the changes made for a remote sync. | 387 // Notify observers of the changes made for a remote sync. |
| 388 FOR_EACH_OBSERVER(SyncEventObserver, observers_, OnFileSynced(url, type)); | 388 FOR_EACH_OBSERVER(SyncEventObserver, observers_, OnFileSynced(url, type)); |
| 389 } else if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { | 389 } else if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { |
| 390 // We seem to have no changes to work on. Reset the pending_remote_changes_ | 390 // We seem to have no changes to work on for now. |
| 391 // and return here. | |
| 392 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. | 391 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. |
| 393 pending_remote_changes_ = 0; | |
| 394 return; | 392 return; |
| 395 } else if (status == fileapi::SYNC_STATUS_FILE_BUSY) { | 393 } else if (status == fileapi::SYNC_STATUS_FILE_BUSY) { |
| 396 is_waiting_remote_sync_enabled_ = true; | 394 is_waiting_remote_sync_enabled_ = true; |
| 397 local_file_service_->RegisterURLForWaitingSync( | 395 local_file_service_->RegisterURLForWaitingSync( |
| 398 url, base::Bind(&SyncFileSystemService::OnSyncEnabledForRemoteSync, | 396 url, base::Bind(&SyncFileSystemService::OnSyncEnabledForRemoteSync, |
| 399 AsWeakPtr())); | 397 AsWeakPtr())); |
| 400 return; | 398 return; |
| 401 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { | 399 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { |
| 402 // TODO(kinuko,tzik): Handle conflict! | 400 // TODO(kinuko,tzik): Handle conflict! |
| 403 } | 401 } |
| 404 base::MessageLoopProxy::current()->PostTask( | 402 base::MessageLoopProxy::current()->PostTask( |
| 405 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, | 403 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, |
| 406 AsWeakPtr())); | 404 AsWeakPtr())); |
| 407 } | 405 } |
| 408 | 406 |
| 409 void SyncFileSystemService::DidProcessLocalChange( | 407 void SyncFileSystemService::DidProcessLocalChange( |
| 410 fileapi::SyncStatusCode status, const FileSystemURL& url) { | 408 fileapi::SyncStatusCode status, const FileSystemURL& url) { |
| 411 DVLOG(1) << "DidProcessLocalChange: " | 409 DVLOG(1) << "DidProcessLocalChange: " |
| 412 << " status=" << status | 410 << " status=" << status |
| 413 << " url=" << url.DebugString(); | 411 << " url=" << url.DebugString(); |
| 414 DCHECK(local_sync_running_); | 412 DCHECK(local_sync_running_); |
| 415 local_sync_running_ = false; | 413 local_sync_running_ = false; |
| 416 if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { | 414 if (status == fileapi::SYNC_STATUS_NO_CHANGE_TO_SYNC) { |
| 417 // We seem to have no changes to work on. Reset the pending_local_changes_ | 415 // We seem to have no changes to work on for now. |
| 418 // and return here. | |
| 419 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. | 416 // TODO(kinuko): Might be better setting a timer to call MaybeStartSync. |
| 420 pending_local_changes_ = 0; | |
| 421 return; | 417 return; |
| 422 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { | 418 } else if (status == fileapi::SYNC_STATUS_HAS_CONFLICT) { |
| 423 // TODO(kinuko,tzik): Handle conflict! | 419 // TODO(kinuko,tzik): Handle conflict! |
| 424 } | 420 } |
| 425 base::MessageLoopProxy::current()->PostTask( | 421 base::MessageLoopProxy::current()->PostTask( |
| 426 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, | 422 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, |
| 427 AsWeakPtr())); | 423 AsWeakPtr())); |
| 428 } | 424 } |
| 429 | 425 |
| 430 void SyncFileSystemService::DidGetLocalChangeStatus( | 426 void SyncFileSystemService::DidGetLocalChangeStatus( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 remote_file_service = mock_remote_file_service_.Pass(); | 519 remote_file_service = mock_remote_file_service_.Pass(); |
| 524 else | 520 else |
| 525 remote_file_service.reset(new DriveFileSyncService(profile)); | 521 remote_file_service.reset(new DriveFileSyncService(profile)); |
| 526 | 522 |
| 527 service->Initialize(local_file_service.Pass(), | 523 service->Initialize(local_file_service.Pass(), |
| 528 remote_file_service.Pass()); | 524 remote_file_service.Pass()); |
| 529 return service; | 525 return service; |
| 530 } | 526 } |
| 531 | 527 |
| 532 } // namespace sync_file_system | 528 } // namespace sync_file_system |
| OLD | NEW |