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

Side by Side Diff: components/ntp_snippets/sessions/tab_delegate_sync_adapter.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ntp_snippets/sessions/tab_delegate_sync_adapter.h" 5 #include "components/ntp_snippets/sessions/tab_delegate_sync_adapter.h"
6 6
7 #include "components/sync/driver/sync_service.h" 7 #include "components/sync/driver/sync_service.h"
8 #include "components/sync_sessions/open_tabs_ui_delegate.h" 8 #include "components/sync_sessions/open_tabs_ui_delegate.h"
9 9
10 using syncer::SyncService; 10 using syncer::SyncService;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // becomes available. Otherwise we might transition to think we have session 55 // becomes available. Otherwise we might transition to think we have session
56 // data, but invoke our callback while the GetOpenTabsUIDelegate() returns bad 56 // data, but invoke our callback while the GetOpenTabsUIDelegate() returns bad
57 // results. Fortunately, this isn't a problem. GetOpenTabsUIDelegate() is 57 // results. Fortunately, this isn't a problem. GetOpenTabsUIDelegate() is
58 // guarded by verifying the data type is RUNNING, which always means the 58 // guarded by verifying the data type is RUNNING, which always means the
59 // sessions merge has already happened. 59 // sessions merge has already happened.
60 if (had_session_data_ != HasSessionsData()) { 60 if (had_session_data_ != HasSessionsData()) {
61 InvokeCallback(); 61 InvokeCallback();
62 } 62 }
63 } 63 }
64 64
65 void TabDelegateSyncAdapter::OnSyncConfigurationCompleted() { 65 void TabDelegateSyncAdapter::OnSyncConfigurationCompleted(
66 syncer::SyncService* sync) {
66 // Ignored. This event can let us know when the set of enabled data types 67 // Ignored. This event can let us know when the set of enabled data types
67 // change. However, we want to avoid useless notifications as much as 68 // change. However, we want to avoid useless notifications as much as
68 // possible, and all of the information captured in this event will also be 69 // possible, and all of the information captured in this event will also be
69 // covered by OnStateChange. 70 // covered by OnStateChange.
70 } 71 }
71 72
72 void TabDelegateSyncAdapter::OnForeignSessionUpdated() { 73 void TabDelegateSyncAdapter::OnForeignSessionUpdated() {
73 // Foreign tab data changed, always invoke the callback to generate new 74 // Foreign tab data changed, always invoke the callback to generate new
74 // suggestions. Interestingly, this is only triggered after sync model type 75 // suggestions. Interestingly, this is only triggered after sync model type
75 // apply, not after merge. The merge case should always be handled by 76 // apply, not after merge. The merge case should always be handled by
76 // OnStateChange. 77 // OnStateChange.
77 InvokeCallback(); 78 InvokeCallback();
78 } 79 }
79 80
80 void TabDelegateSyncAdapter::InvokeCallback() { 81 void TabDelegateSyncAdapter::InvokeCallback() {
81 had_session_data_ = HasSessionsData(); 82 had_session_data_ = HasSessionsData();
82 if (!change_callback_.is_null()) { 83 if (!change_callback_.is_null()) {
83 change_callback_.Run(); 84 change_callback_.Run();
84 } 85 }
85 } 86 }
86 87
87 } // namespace ntp_snippets 88 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698