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

Side by Side Diff: ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions_bridge.mm

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Chromeos fix Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions_bridge.h" 5 #import "ios/chrome/browser/ui/ntp/recent_tabs/synced_sessions_bridge.h"
6 6
7 #include "components/browser_sync/profile_sync_service.h" 7 #include "components/browser_sync/profile_sync_service.h"
8 #include "components/signin/core/browser/signin_manager.h" 8 #include "components/signin/core/browser/signin_manager.h"
9 #include "components/sync/driver/sync_service.h" 9 #include "components/sync/driver/sync_service.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
(...skipping 18 matching lines...) Expand all
29 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browserState)), 29 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browserState)),
30 signin_manager_observer_(this), 30 signin_manager_observer_(this),
31 first_sync_cycle_is_completed_(false) { 31 first_sync_cycle_is_completed_(false) {
32 signin_manager_observer_.Add(signin_manager_); 32 signin_manager_observer_.Add(signin_manager_);
33 } 33 }
34 34
35 SyncedSessionsObserverBridge::~SyncedSessionsObserverBridge() {} 35 SyncedSessionsObserverBridge::~SyncedSessionsObserverBridge() {}
36 36
37 #pragma mark - SyncObserverBridge 37 #pragma mark - SyncObserverBridge
38 38
39 void SyncedSessionsObserverBridge::OnStateChanged() { 39 void SyncedSessionsObserverBridge::OnStateChanged(syncer::SyncService* sync) {
40 if (!signin_manager_->IsAuthenticated()) 40 if (!signin_manager_->IsAuthenticated())
41 first_sync_cycle_is_completed_ = false; 41 first_sync_cycle_is_completed_ = false;
42 [owner_ onSyncStateChanged]; 42 [owner_ onSyncStateChanged];
43 } 43 }
44 44
45 void SyncedSessionsObserverBridge::OnSyncCycleCompleted() { 45 void SyncedSessionsObserverBridge::OnSyncCycleCompleted(
46 syncer::SyncService* sync) {
46 if (sync_service_->GetActiveDataTypes().Has(syncer::SESSIONS)) 47 if (sync_service_->GetActiveDataTypes().Has(syncer::SESSIONS))
47 first_sync_cycle_is_completed_ = true; 48 first_sync_cycle_is_completed_ = true;
48 [owner_ onSyncStateChanged]; 49 [owner_ onSyncStateChanged];
49 } 50 }
50 51
51 void SyncedSessionsObserverBridge::OnSyncConfigurationCompleted() { 52 void SyncedSessionsObserverBridge::OnSyncConfigurationCompleted(
53 syncer::SyncService* sync) {
52 [owner_ reloadSessions]; 54 [owner_ reloadSessions];
53 } 55 }
54 56
55 void SyncedSessionsObserverBridge::OnForeignSessionUpdated() { 57 void SyncedSessionsObserverBridge::OnForeignSessionUpdated(
58 syncer::SyncService* sync) {
56 [owner_ reloadSessions]; 59 [owner_ reloadSessions];
57 } 60 }
58 61
59 bool SyncedSessionsObserverBridge::IsFirstSyncCycleCompleted() { 62 bool SyncedSessionsObserverBridge::IsFirstSyncCycleCompleted() {
60 return first_sync_cycle_is_completed_; 63 return first_sync_cycle_is_completed_;
61 } 64 }
62 65
63 #pragma mark - SigninManagerBase::Observer 66 #pragma mark - SigninManagerBase::Observer
64 67
65 void SyncedSessionsObserverBridge::GoogleSignedOut( 68 void SyncedSessionsObserverBridge::GoogleSignedOut(
66 const std::string& account_id, 69 const std::string& account_id,
67 const std::string& username) { 70 const std::string& username) {
68 first_sync_cycle_is_completed_ = false; 71 first_sync_cycle_is_completed_ = false;
69 [owner_ reloadSessions]; 72 [owner_ reloadSessions];
70 } 73 }
71 74
72 } // namespace synced_sessions 75 } // namespace synced_sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698