Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_core.cc

Issue 566623003: Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - part 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test fixes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/sync/glue/device_info.h" 9 #include "chrome/browser/sync/glue/device_info.h"
10 #include "chrome/browser/sync/glue/invalidation_adapter.h" 10 #include "chrome/browser/sync/glue/invalidation_adapter.h"
11 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 11 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
12 #include "chrome/browser/sync/glue/synced_device_tracker.h"
13 #include "chrome/common/chrome_version_info.h" 12 #include "chrome/common/chrome_version_info.h"
14 #include "components/invalidation/invalidation_util.h" 13 #include "components/invalidation/invalidation_util.h"
15 #include "components/invalidation/object_id_invalidation_map.h" 14 #include "components/invalidation/object_id_invalidation_map.h"
16 #include "sync/internal_api/public/events/protocol_event.h" 15 #include "sync/internal_api/public/events/protocol_event.h"
17 #include "sync/internal_api/public/http_post_provider_factory.h" 16 #include "sync/internal_api/public/http_post_provider_factory.h"
18 #include "sync/internal_api/public/internal_components_factory.h" 17 #include "sync/internal_api/public/internal_components_factory.h"
19 #include "sync/internal_api/public/sessions/commit_counters.h" 18 #include "sync/internal_api/public/sessions/commit_counters.h"
20 #include "sync/internal_api/public/sessions/status_counters.h" 19 #include "sync/internal_api/public/sessions/status_counters.h"
21 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 20 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
22 #include "sync/internal_api/public/sessions/update_counters.h" 21 #include "sync/internal_api/public/sessions/update_counters.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 501 }
503 502
504 if (!sync_manager_->InitialSyncEndedTypes().HasAll(syncer::ControlTypes())) { 503 if (!sync_manager_->InitialSyncEndedTypes().HasAll(syncer::ControlTypes())) {
505 LOG(ERROR) << "Failed to download control types"; 504 LOG(ERROR) << "Failed to download control types";
506 host_.Call( 505 host_.Call(
507 FROM_HERE, 506 FROM_HERE,
508 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); 507 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop);
509 return; 508 return;
510 } 509 }
511 510
512 // Initialize device info. This is asynchronous on some platforms, so we
513 // provide a callback for when it finishes.
514 synced_device_tracker_.reset(
515 new SyncedDeviceTracker(sync_manager_->GetUserShare(),
516 sync_manager_->cache_guid()));
517 synced_device_tracker_->InitLocalDeviceInfo(
518 signin_scoped_device_id_,
519 base::Bind(&SyncBackendHostCore::DoFinishInitialProcessControlTypes,
520 weak_ptr_factory_.GetWeakPtr()));
521 }
522
523 void SyncBackendHostCore::DoFinishInitialProcessControlTypes() {
524 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
525
526 registrar_->ActivateDataType(syncer::DEVICE_INFO,
527 syncer::GROUP_PASSIVE,
528 synced_device_tracker_.get(),
529 sync_manager_->GetUserShare());
530
531 host_.Call(FROM_HERE, 511 host_.Call(FROM_HERE,
532 &SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop, 512 &SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop,
533 js_backend_, 513 js_backend_,
534 debug_info_listener_, 514 debug_info_listener_,
535 sync_manager_->GetSyncContextProxy(), 515 sync_manager_->GetSyncContextProxy(),
536 sync_manager_->cache_guid()); 516 sync_manager_->cache_guid());
537 517
538 js_backend_.Reset(); 518 js_backend_.Reset();
539 debug_info_listener_.Reset(); 519 debug_info_listener_.Reset();
540 } 520 }
(...skipping 27 matching lines...) Expand all
568 // no longer be used to create new HttpBridge instances. We can get away with 548 // no longer be used to create new HttpBridge instances. We can get away with
569 // this because the stop_syncing_signal_ has already been signalled, which 549 // this because the stop_syncing_signal_ has already been signalled, which
570 // guarantees that the ServerConnectionManager will no longer attempt to 550 // guarantees that the ServerConnectionManager will no longer attempt to
571 // create new connections. 551 // create new connections.
572 release_request_context_signal_.Signal(); 552 release_request_context_signal_.Signal();
573 } 553 }
574 554
575 void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) { 555 void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) {
576 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 556 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
577 557
578 // It's safe to do this even if the type was never activated.
579 registrar_->DeactivateDataType(syncer::DEVICE_INFO);
580 synced_device_tracker_.reset();
581
582 DoDestroySyncManager(reason); 558 DoDestroySyncManager(reason);
583 559
584 registrar_ = NULL; 560 registrar_ = NULL;
585 561
586 if (reason == syncer::DISABLE_SYNC) 562 if (reason == syncer::DISABLE_SYNC)
587 DeleteSyncDataFolder(); 563 DeleteSyncDataFolder();
588 564
589 host_.Reset(); 565 host_.Reset();
590 weak_ptr_factory_.InvalidateWeakPtrs(); 566 weak_ptr_factory_.InvalidateWeakPtrs();
591 } 567 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), 732 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
757 this, &SyncBackendHostCore::SaveChanges); 733 this, &SyncBackendHostCore::SaveChanges);
758 } 734 }
759 735
760 void SyncBackendHostCore::SaveChanges() { 736 void SyncBackendHostCore::SaveChanges() {
761 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 737 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
762 sync_manager_->SaveChanges(); 738 sync_manager_->SaveChanges();
763 } 739 }
764 740
765 } // namespace browser_sync 741 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698