| 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/drive_backend/sync_engine.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 callback_tracker_.Register(abort_closure, callback); | 569 callback_tracker_.Register(abort_closure, callback); |
| 570 | 570 |
| 571 PostTaskAndReplyWithResult(worker_task_runner_.get(), | 571 PostTaskAndReplyWithResult(worker_task_runner_.get(), |
| 572 FROM_HERE, | 572 FROM_HERE, |
| 573 base::Bind(&SyncWorkerInterface::DumpDatabase, | 573 base::Bind(&SyncWorkerInterface::DumpDatabase, |
| 574 base::Unretained(sync_worker_.get())), | 574 base::Unretained(sync_worker_.get())), |
| 575 tracked_callback); | 575 tracked_callback); |
| 576 } | 576 } |
| 577 | 577 |
| 578 void SyncEngine::SetSyncEnabled(bool sync_enabled) { | 578 void SyncEngine::SetSyncEnabled(bool sync_enabled) { |
| 579 if (sync_enabled_ == sync_enabled) |
| 580 return; |
| 579 sync_enabled_ = sync_enabled; | 581 sync_enabled_ = sync_enabled; |
| 580 | 582 |
| 583 if (sync_enabled_) { |
| 584 if (!sync_worker_) |
| 585 Initialize(); |
| 586 |
| 587 // Have no login credential. |
| 588 if (!sync_worker_) |
| 589 return; |
| 590 |
| 591 worker_task_runner_->PostTask( |
| 592 FROM_HERE, |
| 593 base::Bind(&SyncWorkerInterface::SetSyncEnabled, |
| 594 base::Unretained(sync_worker_.get()), |
| 595 sync_enabled_)); |
| 596 return; |
| 597 } |
| 598 |
| 581 if (!sync_worker_) | 599 if (!sync_worker_) |
| 582 return; | 600 return; |
| 583 | 601 |
| 602 // TODO(tzik): Consider removing SyncWorkerInterface::SetSyncEnabled and |
| 603 // let SyncEngine handle the flag. |
| 584 worker_task_runner_->PostTask( | 604 worker_task_runner_->PostTask( |
| 585 FROM_HERE, | 605 FROM_HERE, |
| 586 base::Bind(&SyncWorkerInterface::SetSyncEnabled, | 606 base::Bind(&SyncWorkerInterface::SetSyncEnabled, |
| 587 base::Unretained(sync_worker_.get()), | 607 base::Unretained(sync_worker_.get()), |
| 588 sync_enabled)); | 608 sync_enabled_)); |
| 609 Reset(); |
| 589 } | 610 } |
| 590 | 611 |
| 591 void SyncEngine::PromoteDemotedChanges(const base::Closure& callback) { | 612 void SyncEngine::PromoteDemotedChanges(const base::Closure& callback) { |
| 592 if (!sync_worker_) { | 613 if (!sync_worker_) { |
| 593 callback.Run(); | 614 callback.Run(); |
| 594 return; | 615 return; |
| 595 } | 616 } |
| 596 | 617 |
| 597 base::Closure relayed_callback = RelayCallbackToCurrentThread( | 618 base::Closure relayed_callback = RelayCallbackToCurrentThread( |
| 598 FROM_HERE, callback_tracker_.Register(callback, callback)); | 619 FROM_HERE, callback_tracker_.Register(callback, callback)); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 803 |
| 783 SyncStatusCallback SyncEngine::TrackCallback( | 804 SyncStatusCallback SyncEngine::TrackCallback( |
| 784 const SyncStatusCallback& callback) { | 805 const SyncStatusCallback& callback) { |
| 785 return callback_tracker_.Register( | 806 return callback_tracker_.Register( |
| 786 base::Bind(callback, SYNC_STATUS_ABORT), | 807 base::Bind(callback, SYNC_STATUS_ABORT), |
| 787 callback); | 808 callback); |
| 788 } | 809 } |
| 789 | 810 |
| 790 } // namespace drive_backend | 811 } // namespace drive_backend |
| 791 } // namespace sync_file_system | 812 } // namespace sync_file_system |
| OLD | NEW |