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/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/location.h" |
8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/single_thread_task_runner.h" |
9 #include "chrome/browser/sync/glue/invalidation_adapter.h" | 11 #include "chrome/browser/sync/glue/invalidation_adapter.h" |
10 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" | 12 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" |
11 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 13 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
12 #include "chrome/common/chrome_version_info.h" | 14 #include "chrome/common/chrome_version_info.h" |
13 #include "components/invalidation/invalidation_util.h" | 15 #include "components/invalidation/invalidation_util.h" |
14 #include "components/invalidation/object_id_invalidation_map.h" | 16 #include "components/invalidation/object_id_invalidation_map.h" |
15 #include "sync/internal_api/public/events/protocol_event.h" | 17 #include "sync/internal_api/public/events/protocol_event.h" |
16 #include "sync/internal_api/public/http_post_provider_factory.h" | 18 #include "sync/internal_api/public/http_post_provider_factory.h" |
17 #include "sync/internal_api/public/internal_components_factory.h" | 19 #include "sync/internal_api/public/internal_components_factory.h" |
18 #include "sync/internal_api/public/sessions/commit_counters.h" | 20 #include "sync/internal_api/public/sessions/commit_counters.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 152 } |
151 | 153 |
152 // Register for encryption related changes now. We have to do this before | 154 // Register for encryption related changes now. We have to do this before |
153 // the initializing downloading control types or initializing the encryption | 155 // the initializing downloading control types or initializing the encryption |
154 // handler in order to receive notifications triggered during encryption | 156 // handler in order to receive notifications triggered during encryption |
155 // startup. | 157 // startup. |
156 sync_manager_->GetEncryptionHandler()->AddObserver(this); | 158 sync_manager_->GetEncryptionHandler()->AddObserver(this); |
157 | 159 |
158 // Sync manager initialization is complete, so we can schedule recurring | 160 // Sync manager initialization is complete, so we can schedule recurring |
159 // SaveChanges. | 161 // SaveChanges. |
160 sync_loop_->PostTask(FROM_HERE, | 162 sync_loop_->task_runner()->PostTask( |
161 base::Bind(&SyncBackendHostCore::StartSavingChanges, | 163 FROM_HERE, base::Bind(&SyncBackendHostCore::StartSavingChanges, |
162 weak_ptr_factory_.GetWeakPtr())); | 164 weak_ptr_factory_.GetWeakPtr())); |
163 | 165 |
164 // Hang on to these for a while longer. We're not ready to hand them back to | 166 // Hang on to these for a while longer. We're not ready to hand them back to |
165 // the UI thread yet. | 167 // the UI thread yet. |
166 js_backend_ = js_backend; | 168 js_backend_ = js_backend; |
167 debug_info_listener_ = debug_info_listener; | 169 debug_info_listener_ = debug_info_listener; |
168 | 170 |
169 // Track whether or not sync DB and preferences were in sync. | 171 // Track whether or not sync DB and preferences were in sync. |
170 SyncBackendInitState backend_init_state; | 172 SyncBackendInitState backend_init_state; |
171 if (has_sync_setup_completed_ && !restored_types.Empty()) { | 173 if (has_sync_setup_completed_ && !restored_types.Empty()) { |
172 backend_init_state = SETUP_COMPLETED_FOUND_RESTORED_TYPES; | 174 backend_init_state = SETUP_COMPLETED_FOUND_RESTORED_TYPES; |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), | 724 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), |
723 this, &SyncBackendHostCore::SaveChanges); | 725 this, &SyncBackendHostCore::SaveChanges); |
724 } | 726 } |
725 | 727 |
726 void SyncBackendHostCore::SaveChanges() { | 728 void SyncBackendHostCore::SaveChanges() { |
727 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 729 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
728 sync_manager_->SaveChanges(); | 730 sync_manager_->SaveChanges(); |
729 } | 731 } |
730 | 732 |
731 } // namespace browser_sync | 733 } // namespace browser_sync |
OLD | NEW |