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

Side by Side Diff: chrome/browser/sync/glue/bookmark_model_associator.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/bookmark_model_associator.h" 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/thread_task_runner_handle.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 21 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
21 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 22 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
22 #include "components/bookmarks/browser/bookmark_client.h" 23 #include "components/bookmarks/browser/bookmark_client.h"
23 #include "components/bookmarks/browser/bookmark_model.h" 24 #include "components/bookmarks/browser/bookmark_model.h"
24 #include "components/undo/bookmark_undo_service.h" 25 #include "components/undo/bookmark_undo_service.h"
25 #include "components/undo/bookmark_undo_utils.h" 26 #include "components/undo/bookmark_undo_utils.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "sync/api/sync_error.h" 28 #include "sync/api/sync_error.h"
28 #include "sync/internal_api/public/delete_journal.h" 29 #include "sync/internal_api/public/delete_journal.h"
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 // Purge unmatched journals. 970 // Purge unmatched journals.
970 for (size_t i = 0; i < num_journals_unmatched; ++i) 971 for (size_t i = 0; i < num_journals_unmatched; ++i)
971 journals_to_purge.insert(bk_delete_journals[i].id); 972 journals_to_purge.insert(bk_delete_journals[i].id);
972 syncer::DeleteJournal::PurgeDeleteJournals(trans, journals_to_purge); 973 syncer::DeleteJournal::PurgeDeleteJournals(trans, journals_to_purge);
973 } 974 }
974 975
975 void BookmarkModelAssociator::PostPersistAssociationsTask() { 976 void BookmarkModelAssociator::PostPersistAssociationsTask() {
976 // No need to post a task if a task is already pending. 977 // No need to post a task if a task is already pending.
977 if (weak_factory_.HasWeakPtrs()) 978 if (weak_factory_.HasWeakPtrs())
978 return; 979 return;
979 base::MessageLoop::current()->PostTask( 980 base::ThreadTaskRunnerHandle::Get()->PostTask(
980 FROM_HERE, 981 FROM_HERE, base::Bind(&BookmarkModelAssociator::PersistAssociations,
981 base::Bind( 982 weak_factory_.GetWeakPtr()));
982 &BookmarkModelAssociator::PersistAssociations,
983 weak_factory_.GetWeakPtr()));
984 } 983 }
985 984
986 void BookmarkModelAssociator::PersistAssociations() { 985 void BookmarkModelAssociator::PersistAssociations() {
987 // If there are no dirty associations we have nothing to do. We handle this 986 // If there are no dirty associations we have nothing to do. We handle this
988 // explicity instead of letting the for loop do it to avoid creating a write 987 // explicity instead of letting the for loop do it to avoid creating a write
989 // transaction in this case. 988 // transaction in this case.
990 if (dirty_associations_sync_ids_.empty()) { 989 if (dirty_associations_sync_ids_.empty()) {
991 DCHECK(id_map_.empty()); 990 DCHECK(id_map_.empty());
992 DCHECK(id_map_inverse_.empty()); 991 DCHECK(id_map_inverse_.empty());
993 return; 992 return;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 syncer::BOOKMARKS); 1070 syncer::BOOKMARKS);
1072 } else { 1071 } else {
1073 context->set_native_model_sync_state(BEHIND); 1072 context->set_native_model_sync_state(BEHIND);
1074 } 1073 }
1075 } 1074 }
1076 } 1075 }
1077 return syncer::SyncError(); 1076 return syncer::SyncError();
1078 } 1077 }
1079 1078
1080 } // namespace browser_sync 1079 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698