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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 | 571 |
572 PostTaskAndReplyWithResult( | 572 PostTaskAndReplyWithResult( |
573 worker_task_runner_, | 573 worker_task_runner_, |
574 FROM_HERE, | 574 FROM_HERE, |
575 base::Bind(&SyncWorkerInterface::DumpDatabase, | 575 base::Bind(&SyncWorkerInterface::DumpDatabase, |
576 base::Unretained(sync_worker_.get())), | 576 base::Unretained(sync_worker_.get())), |
577 tracked_callback); | 577 tracked_callback); |
578 } | 578 } |
579 | 579 |
580 void SyncEngine::SetSyncEnabled(bool sync_enabled) { | 580 void SyncEngine::SetSyncEnabled(bool sync_enabled) { |
581 if (sync_enabled_ == sync_enabled) | |
582 return; | |
581 sync_enabled_ = sync_enabled; | 583 sync_enabled_ = sync_enabled; |
582 | 584 |
585 if (sync_enabled_) { | |
586 if (!sync_worker_) | |
587 Initialize(); | |
588 | |
589 // Have no login credential. | |
590 if (!sync_worker_) | |
591 return; | |
592 | |
593 worker_task_runner_->PostTask( | |
594 FROM_HERE, | |
595 base::Bind(&SyncWorkerInterface::SetSyncEnabled, | |
596 base::Unretained(sync_worker_.get()), | |
597 sync_enabled_)); | |
598 return; | |
599 } | |
600 | |
601 DCHECK(!sync_enabled_); | |
peria
2014/08/21 08:34:33
nit: This DCHECK looks unnecessary
tzik
2014/08/21 09:23:35
Done.
| |
602 | |
583 if (!sync_worker_) | 603 if (!sync_worker_) |
584 return; | 604 return; |
585 | 605 |
606 // TODO(tzik): Consider removing SyncWorkerInterface::SetSyncEnabled and | |
607 // let SyncEngine handle the flag. | |
586 worker_task_runner_->PostTask( | 608 worker_task_runner_->PostTask( |
587 FROM_HERE, | 609 FROM_HERE, |
588 base::Bind(&SyncWorkerInterface::SetSyncEnabled, | 610 base::Bind(&SyncWorkerInterface::SetSyncEnabled, |
589 base::Unretained(sync_worker_.get()), | 611 base::Unretained(sync_worker_.get()), |
590 sync_enabled)); | 612 sync_enabled_)); |
613 Reset(); | |
591 } | 614 } |
592 | 615 |
593 void SyncEngine::PromoteDemotedChanges(const base::Closure& callback) { | 616 void SyncEngine::PromoteDemotedChanges(const base::Closure& callback) { |
594 if (!sync_worker_) { | 617 if (!sync_worker_) { |
595 callback.Run(); | 618 callback.Run(); |
596 return; | 619 return; |
597 } | 620 } |
598 | 621 |
599 base::Closure relayed_callback = RelayCallbackToCurrentThread( | 622 base::Closure relayed_callback = RelayCallbackToCurrentThread( |
600 FROM_HERE, callback_tracker_.Register(callback, callback)); | 623 FROM_HERE, callback_tracker_.Register(callback, callback)); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 | 806 |
784 SyncStatusCallback SyncEngine::TrackCallback( | 807 SyncStatusCallback SyncEngine::TrackCallback( |
785 const SyncStatusCallback& callback) { | 808 const SyncStatusCallback& callback) { |
786 return callback_tracker_.Register( | 809 return callback_tracker_.Register( |
787 base::Bind(callback, SYNC_STATUS_ABORT), | 810 base::Bind(callback, SYNC_STATUS_ABORT), |
788 callback); | 811 callback); |
789 } | 812 } |
790 | 813 |
791 } // namespace drive_backend | 814 } // namespace drive_backend |
792 } // namespace sync_file_system | 815 } // namespace sync_file_system |
OLD | NEW |