OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/synced_notifications_private/synced_noti
fications_shim.h" | 5 #include "chrome/browser/extensions/api/synced_notifications_private/synced_noti
fications_shim.h" |
6 | 6 |
7 #include "extensions/browser/event_router.h" | 7 #include "extensions/browser/event_router.h" |
8 #include "sync/api/sync_change.h" | 8 #include "sync/api/sync_change.h" |
9 #include "sync/api/sync_data.h" | 9 #include "sync/api/sync_data.h" |
10 #include "sync/api/sync_error_factory.h" | 10 #include "sync/api/sync_error_factory.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return false; | 122 return false; |
123 } | 123 } |
124 js_data_list->push_back(js_data); | 124 js_data_list->push_back(js_data); |
125 } | 125 } |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 SyncedNotificationsShim::SyncedNotificationsShim( | 131 SyncedNotificationsShim::SyncedNotificationsShim( |
132 const EventLauncher& event_launcher) | 132 const EventLauncher& event_launcher, |
133 : event_launcher_(event_launcher) { | 133 const base::Closure& refresh_request) |
| 134 : event_launcher_(event_launcher), |
| 135 refresh_request_(refresh_request) { |
134 } | 136 } |
135 | 137 |
136 SyncedNotificationsShim::~SyncedNotificationsShim() { | 138 SyncedNotificationsShim::~SyncedNotificationsShim() { |
137 } | 139 } |
138 | 140 |
139 syncer::SyncMergeResult SyncedNotificationsShim::MergeDataAndStartSyncing( | 141 syncer::SyncMergeResult SyncedNotificationsShim::MergeDataAndStartSyncing( |
140 syncer::ModelType type, | 142 syncer::ModelType type, |
141 const syncer::SyncDataList& initial_sync_data, | 143 const syncer::SyncDataList& initial_sync_data, |
142 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 144 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
143 scoped_ptr<syncer::SyncErrorFactory> error_handler) { | 145 scoped_ptr<syncer::SyncErrorFactory> error_handler) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return false; | 235 return false; |
234 | 236 |
235 syncer::SyncChangeProcessor::ContextRefreshStatus sync_refresh_status = | 237 syncer::SyncChangeProcessor::ContextRefreshStatus sync_refresh_status = |
236 refresh_request == | 238 refresh_request == |
237 synced_notifications_private::REFRESH_REQUEST_REFRESH_NEEDED | 239 synced_notifications_private::REFRESH_REQUEST_REFRESH_NEEDED |
238 ? syncer::SyncChangeProcessor::REFRESH_NEEDED | 240 ? syncer::SyncChangeProcessor::REFRESH_NEEDED |
239 : syncer::SyncChangeProcessor::NO_REFRESH; | 241 : syncer::SyncChangeProcessor::NO_REFRESH; |
240 syncer::SyncError error = | 242 syncer::SyncError error = |
241 notifications_change_processor_->UpdateDataTypeContext( | 243 notifications_change_processor_->UpdateDataTypeContext( |
242 syncer::SYNCED_NOTIFICATIONS, sync_refresh_status, new_context); | 244 syncer::SYNCED_NOTIFICATIONS, sync_refresh_status, new_context); |
| 245 |
| 246 if (sync_refresh_status == syncer::SyncChangeProcessor::REFRESH_NEEDED && |
| 247 !refresh_request_.is_null()) { |
| 248 refresh_request_.Run(); |
| 249 } |
| 250 |
243 return !error.IsSet(); | 251 return !error.IsSet(); |
244 } | 252 } |
245 | 253 |
246 bool SyncedNotificationsShim::IsSyncReady() const { | 254 bool SyncedNotificationsShim::IsSyncReady() const { |
247 return notifications_change_processor_ && app_info_change_processor_; | 255 return notifications_change_processor_ && app_info_change_processor_; |
248 } | 256 } |
OLD | NEW |