OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/session_change_processor.h" | 5 #include "chrome/browser/sync/glue/session_change_processor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 chrome::NOTIFICATION_SYNC_REFRESH, | 207 chrome::NOTIFICATION_SYNC_REFRESH, |
208 content::Source<Profile>(profile_), | 208 content::Source<Profile>(profile_), |
209 content::Details<const syncable::ModelType>(&type)); | 209 content::Details<const syncable::ModelType>(&type)); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 // Associate tabs first so the synced session tracker is aware of them. | 213 // Associate tabs first so the synced session tracker is aware of them. |
214 // Note that if we fail to associate, it means something has gone wrong, | 214 // Note that if we fail to associate, it means something has gone wrong, |
215 // such as our local session being deleted, so we disassociate and associate | 215 // such as our local session being deleted, so we disassociate and associate |
216 // again. | 216 // again. |
217 SyncError error; | |
218 bool reassociation_needed = !modified_tabs.empty() && | 217 bool reassociation_needed = !modified_tabs.empty() && |
219 !session_model_associator_->AssociateTabs(modified_tabs, &error); | 218 !session_model_associator_->AssociateTabs(modified_tabs, NULL); |
220 | 219 |
221 // Note, we always associate windows because it's possible a tab became | 220 // Note, we always associate windows because it's possible a tab became |
222 // "interesting" by going to a valid URL, in which case it needs to be added | 221 // "interesting" by going to a valid URL, in which case it needs to be added |
223 // to the window's tab information. | 222 // to the window's tab information. |
224 if (!reassociation_needed) { | 223 if (!reassociation_needed) { |
225 reassociation_needed = | 224 reassociation_needed = |
226 !session_model_associator_->AssociateWindows(false, &error); | 225 !session_model_associator_->AssociateWindows(false, NULL); |
227 } | 226 } |
228 | 227 |
229 if (reassociation_needed) { | 228 if (reassociation_needed) { |
230 LOG(WARNING) << "Reassociation of local models triggered."; | 229 LOG(WARNING) << "Reassociation of local models triggered."; |
231 // Needing to reassociate would have set the error already so clear it. | 230 SyncError error; |
232 error = SyncError(); | 231 error = session_model_associator_->DisassociateModels(); |
233 session_model_associator_->DisassociateModels(&error); | 232 error = session_model_associator_->AssociateModels(); |
234 session_model_associator_->AssociateModels(&error); | |
235 if (error.IsSet()) { | 233 if (error.IsSet()) { |
236 error_handler()->OnSingleDatatypeUnrecoverableError( | 234 error_handler()->OnSingleDatatypeUnrecoverableError( |
237 error.location(), | 235 error.location(), |
238 error.message()); | 236 error.message()); |
239 } | 237 } |
240 } | 238 } |
241 } | 239 } |
242 | 240 |
243 void SessionChangeProcessor::ApplyChangesFromSyncModel( | 241 void SessionChangeProcessor::ApplyChangesFromSyncModel( |
244 const sync_api::BaseTransaction* trans, | 242 const sync_api::BaseTransaction* trans, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 351 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
354 content::NotificationService::AllBrowserContextsAndSources()); | 352 content::NotificationService::AllBrowserContextsAndSources()); |
355 } | 353 } |
356 | 354 |
357 void SessionChangeProcessor::StopObserving() { | 355 void SessionChangeProcessor::StopObserving() { |
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
359 notification_registrar_.RemoveAll(); | 357 notification_registrar_.RemoveAll(); |
360 } | 358 } |
361 | 359 |
362 } // namespace browser_sync | 360 } // namespace browser_sync |
OLD | NEW |