| 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/glue/sync_backend_host_core.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/sync/glue/device_info.h" | 10 #include "chrome/browser/sync/glue/device_info.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const base::FilePath& sync_data_folder_path, | 102 const base::FilePath& sync_data_folder_path, |
| 103 bool has_sync_setup_completed, | 103 bool has_sync_setup_completed, |
| 104 const base::WeakPtr<SyncBackendHostImpl>& backend) | 104 const base::WeakPtr<SyncBackendHostImpl>& backend) |
| 105 : name_(name), | 105 : name_(name), |
| 106 sync_data_folder_path_(sync_data_folder_path), | 106 sync_data_folder_path_(sync_data_folder_path), |
| 107 host_(backend), | 107 host_(backend), |
| 108 sync_loop_(NULL), | 108 sync_loop_(NULL), |
| 109 registrar_(NULL), | 109 registrar_(NULL), |
| 110 has_sync_setup_completed_(has_sync_setup_completed), | 110 has_sync_setup_completed_(has_sync_setup_completed), |
| 111 forward_protocol_events_(false), | 111 forward_protocol_events_(false), |
| 112 forward_type_info_(false), |
| 112 weak_ptr_factory_(this) { | 113 weak_ptr_factory_(this) { |
| 113 DCHECK(backend.get()); | 114 DCHECK(backend.get()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 SyncBackendHostCore::~SyncBackendHostCore() { | 117 SyncBackendHostCore::~SyncBackendHostCore() { |
| 117 DCHECK(!sync_manager_.get()); | 118 DCHECK(!sync_manager_.get()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void SyncBackendHostCore::OnSyncCycleCompleted( | 121 void SyncBackendHostCore::OnSyncCycleCompleted( |
| 121 const syncer::sessions::SyncSessionSnapshot& snapshot) { | 122 const syncer::sessions::SyncSessionSnapshot& snapshot) { |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 if (sync_disabled) | 571 if (sync_disabled) |
| 571 DeleteSyncDataFolder(); | 572 DeleteSyncDataFolder(); |
| 572 | 573 |
| 573 host_.Reset(); | 574 host_.Reset(); |
| 574 weak_ptr_factory_.InvalidateWeakPtrs(); | 575 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 575 } | 576 } |
| 576 | 577 |
| 577 void SyncBackendHostCore::DoDestroySyncManager() { | 578 void SyncBackendHostCore::DoDestroySyncManager() { |
| 578 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 579 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 579 if (sync_manager_) { | 580 if (sync_manager_) { |
| 581 DisableDirectoryTypeDebugInfoForwarding(); |
| 580 save_changes_timer_.reset(); | 582 save_changes_timer_.reset(); |
| 581 DisableDirectoryTypeDebugInfoForwarding(); | |
| 582 sync_manager_->RemoveObserver(this); | 583 sync_manager_->RemoveObserver(this); |
| 583 sync_manager_->ShutdownOnSyncThread(); | 584 sync_manager_->ShutdownOnSyncThread(); |
| 584 sync_manager_.reset(); | 585 sync_manager_.reset(); |
| 585 } | 586 } |
| 586 } | 587 } |
| 587 | 588 |
| 588 void SyncBackendHostCore::DoConfigureSyncer( | 589 void SyncBackendHostCore::DoConfigureSyncer( |
| 589 syncer::ConfigureReason reason, | 590 syncer::ConfigureReason reason, |
| 590 const DoConfigureSyncerTypes& config_types, | 591 const DoConfigureSyncerTypes& config_types, |
| 591 const syncer::ModelSafeRoutingInfo routing_info, | 592 const syncer::ModelSafeRoutingInfo routing_info, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 } | 663 } |
| 663 } | 664 } |
| 664 } | 665 } |
| 665 | 666 |
| 666 void SyncBackendHostCore::DisableProtocolEventForwarding() { | 667 void SyncBackendHostCore::DisableProtocolEventForwarding() { |
| 667 forward_protocol_events_ = false; | 668 forward_protocol_events_ = false; |
| 668 } | 669 } |
| 669 | 670 |
| 670 void SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding() { | 671 void SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding() { |
| 671 DCHECK(sync_manager_); | 672 DCHECK(sync_manager_); |
| 673 |
| 674 forward_type_info_ = true; |
| 675 |
| 672 if (!sync_manager_->HasDirectoryTypeDebugInfoObserver(this)) | 676 if (!sync_manager_->HasDirectoryTypeDebugInfoObserver(this)) |
| 673 sync_manager_->RegisterDirectoryTypeDebugInfoObserver(this); | 677 sync_manager_->RegisterDirectoryTypeDebugInfoObserver(this); |
| 674 sync_manager_->RequestEmitDebugInfo(); | 678 sync_manager_->RequestEmitDebugInfo(); |
| 675 } | 679 } |
| 676 | 680 |
| 677 void SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding() { | 681 void SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding() { |
| 678 DCHECK(sync_manager_); | 682 DCHECK(sync_manager_); |
| 683 |
| 684 if (!forward_type_info_) |
| 685 return; |
| 686 |
| 687 forward_type_info_ = false; |
| 688 |
| 679 if (sync_manager_->HasDirectoryTypeDebugInfoObserver(this)) | 689 if (sync_manager_->HasDirectoryTypeDebugInfoObserver(this)) |
| 680 sync_manager_->UnregisterDirectoryTypeDebugInfoObserver(this); | 690 sync_manager_->UnregisterDirectoryTypeDebugInfoObserver(this); |
| 681 } | 691 } |
| 682 | 692 |
| 683 void SyncBackendHostCore::DeleteSyncDataFolder() { | 693 void SyncBackendHostCore::DeleteSyncDataFolder() { |
| 684 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 694 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 685 if (base::DirectoryExists(sync_data_folder_path_)) { | 695 if (base::DirectoryExists(sync_data_folder_path_)) { |
| 686 if (!base::DeleteFile(sync_data_folder_path_, true)) | 696 if (!base::DeleteFile(sync_data_folder_path_, true)) |
| 687 SLOG(DFATAL) << "Could not delete the Sync Data folder."; | 697 SLOG(DFATAL) << "Could not delete the Sync Data folder."; |
| 688 } | 698 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 this, &SyncBackendHostCore::SaveChanges); | 737 this, &SyncBackendHostCore::SaveChanges); |
| 728 } | 738 } |
| 729 | 739 |
| 730 void SyncBackendHostCore::SaveChanges() { | 740 void SyncBackendHostCore::SaveChanges() { |
| 731 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 741 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 732 sync_manager_->SaveChanges(); | 742 sync_manager_->SaveChanges(); |
| 733 } | 743 } |
| 734 | 744 |
| 735 } // namespace browser_sync | 745 } // namespace browser_sync |
| 736 | 746 |
| OLD | NEW |