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 // Needing to reassociate would have set the error already so clear it. |
Nicolas Zea
2012/04/05 22:08:58
remove comment.
lipalani1
2012/04/05 22:51:03
Done.
| |
232 error = SyncError(); | 231 SyncError error; |
233 session_model_associator_->DisassociateModels(&error); | 232 error = session_model_associator_->DisassociateModels(); |
234 session_model_associator_->AssociateModels(&error); | 233 error = session_model_associator_->AssociateModels(); |
235 if (error.IsSet()) { | 234 if (error.IsSet()) { |
236 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, | 235 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, |
237 "Sessions reassociation failed."); | 236 "Sessions reassociation failed."); |
238 } | 237 } |
239 } | 238 } |
240 } | 239 } |
241 | 240 |
242 void SessionChangeProcessor::ApplyChangesFromSyncModel( | 241 void SessionChangeProcessor::ApplyChangesFromSyncModel( |
243 const sync_api::BaseTransaction* trans, | 242 const sync_api::BaseTransaction* trans, |
244 const sync_api::ImmutableChangeRecordList& changes) { | 243 const sync_api::ImmutableChangeRecordList& changes) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 351 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
353 content::NotificationService::AllBrowserContextsAndSources()); | 352 content::NotificationService::AllBrowserContextsAndSources()); |
354 } | 353 } |
355 | 354 |
356 void SessionChangeProcessor::StopObserving() { | 355 void SessionChangeProcessor::StopObserving() { |
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
358 notification_registrar_.RemoveAll(); | 357 notification_registrar_.RemoveAll(); |
359 } | 358 } |
360 | 359 |
361 } // namespace browser_sync | 360 } // namespace browser_sync |
OLD | NEW |