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