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

Side by Side Diff: chrome/browser/history/typed_url_syncable_service.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/history/typed_url_syncable_service.h" 5 #include "chrome/browser/history/typed_url_syncable_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 previous_visit_time = visit->visit_time.ToInternalValue(); 58 previous_visit_time = visit->visit_time.ToInternalValue();
59 } 59 }
60 return true; 60 return true;
61 } 61 }
62 62
63 TypedUrlSyncableService::TypedUrlSyncableService( 63 TypedUrlSyncableService::TypedUrlSyncableService(
64 HistoryBackend* history_backend) 64 HistoryBackend* history_backend)
65 : history_backend_(history_backend), 65 : history_backend_(history_backend),
66 processing_syncer_changes_(false), 66 processing_syncer_changes_(false),
67 expected_loop_(MessageLoop::current()) { 67 expected_loop_(base::MessageLoop::current()) {
68 DCHECK(history_backend_); 68 DCHECK(history_backend_);
69 DCHECK(expected_loop_ == MessageLoop::current()); 69 DCHECK(expected_loop_ == base::MessageLoop::current());
70 } 70 }
71 71
72 TypedUrlSyncableService::~TypedUrlSyncableService() { 72 TypedUrlSyncableService::~TypedUrlSyncableService() {
73 DCHECK(expected_loop_ == MessageLoop::current()); 73 DCHECK(expected_loop_ == base::MessageLoop::current());
74 } 74 }
75 75
76 syncer::SyncMergeResult TypedUrlSyncableService::MergeDataAndStartSyncing( 76 syncer::SyncMergeResult TypedUrlSyncableService::MergeDataAndStartSyncing(
77 syncer::ModelType type, 77 syncer::ModelType type,
78 const syncer::SyncDataList& initial_sync_data, 78 const syncer::SyncDataList& initial_sync_data,
79 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 79 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
80 scoped_ptr<syncer::SyncErrorFactory> error_handler) { 80 scoped_ptr<syncer::SyncErrorFactory> error_handler) {
81 DCHECK(expected_loop_ == MessageLoop::current()); 81 DCHECK(expected_loop_ == base::MessageLoop::current());
82 DCHECK(!sync_processor_.get()); 82 DCHECK(!sync_processor_.get());
83 DCHECK(sync_processor.get()); 83 DCHECK(sync_processor.get());
84 DCHECK(error_handler.get()); 84 DCHECK(error_handler.get());
85 DCHECK_EQ(type, syncer::TYPED_URLS); 85 DCHECK_EQ(type, syncer::TYPED_URLS);
86 86
87 syncer::SyncMergeResult merge_result(type); 87 syncer::SyncMergeResult merge_result(type);
88 sync_processor_ = sync_processor.Pass(); 88 sync_processor_ = sync_processor.Pass();
89 sync_error_handler_ = error_handler.Pass(); 89 sync_error_handler_ = error_handler.Pass();
90 90
91 // TODO(mgist): Add implementation 91 // TODO(mgist): Add implementation
92 92
93 return merge_result; 93 return merge_result;
94 } 94 }
95 95
96 void TypedUrlSyncableService::StopSyncing(syncer::ModelType type) { 96 void TypedUrlSyncableService::StopSyncing(syncer::ModelType type) {
97 DCHECK(expected_loop_ == MessageLoop::current()); 97 DCHECK(expected_loop_ == base::MessageLoop::current());
98 DCHECK_EQ(type, syncer::TYPED_URLS); 98 DCHECK_EQ(type, syncer::TYPED_URLS);
99 99
100 sync_processor_.reset(); 100 sync_processor_.reset();
101 sync_error_handler_.reset(); 101 sync_error_handler_.reset();
102 } 102 }
103 103
104 syncer::SyncDataList TypedUrlSyncableService::GetAllSyncData( 104 syncer::SyncDataList TypedUrlSyncableService::GetAllSyncData(
105 syncer::ModelType type) const { 105 syncer::ModelType type) const {
106 DCHECK(expected_loop_ == MessageLoop::current()); 106 DCHECK(expected_loop_ == base::MessageLoop::current());
107 syncer::SyncDataList list; 107 syncer::SyncDataList list;
108 108
109 // TODO(mgist): Add implementation 109 // TODO(mgist): Add implementation
110 110
111 return list; 111 return list;
112 } 112 }
113 113
114 syncer::SyncError TypedUrlSyncableService::ProcessSyncChanges( 114 syncer::SyncError TypedUrlSyncableService::ProcessSyncChanges(
115 const tracked_objects::Location& from_here, 115 const tracked_objects::Location& from_here,
116 const syncer::SyncChangeList& change_list) { 116 const syncer::SyncChangeList& change_list) {
117 DCHECK(expected_loop_ == MessageLoop::current()); 117 DCHECK(expected_loop_ == base::MessageLoop::current());
118 118
119 // TODO(mgist): Add implementation 119 // TODO(mgist): Add implementation
120 120
121 return syncer::SyncError(FROM_HERE, 121 return syncer::SyncError(FROM_HERE,
122 "Typed url syncable service is not implemented.", 122 "Typed url syncable service is not implemented.",
123 syncer::TYPED_URLS); 123 syncer::TYPED_URLS);
124 } 124 }
125 125
126 void TypedUrlSyncableService::OnUrlsModified(URLRows* changed_urls) { 126 void TypedUrlSyncableService::OnUrlsModified(URLRows* changed_urls) {
127 DCHECK(expected_loop_ == MessageLoop::current()); 127 DCHECK(expected_loop_ == base::MessageLoop::current());
128 DCHECK(changed_urls); 128 DCHECK(changed_urls);
129 129
130 if (processing_syncer_changes_) 130 if (processing_syncer_changes_)
131 return; // These are changes originating from us, ignore. 131 return; // These are changes originating from us, ignore.
132 if (!sync_processor_.get()) 132 if (!sync_processor_.get())
133 return; // Sync processor not yet initialized, don't sync. 133 return; // Sync processor not yet initialized, don't sync.
134 134
135 // Create SyncChangeList. 135 // Create SyncChangeList.
136 syncer::SyncChangeList changes; 136 syncer::SyncChangeList changes;
137 137
138 for (URLRows::iterator url = changed_urls->begin(); 138 for (URLRows::iterator url = changed_urls->begin();
139 url != changed_urls->end(); ++url) { 139 url != changed_urls->end(); ++url) {
140 // Only care if the modified URL is typed. 140 // Only care if the modified URL is typed.
141 if (url->typed_count() > 0) { 141 if (url->typed_count() > 0) {
142 // If there were any errors updating the sync node, just ignore them and 142 // If there were any errors updating the sync node, just ignore them and
143 // continue on to process the next URL. 143 // continue on to process the next URL.
144 CreateOrUpdateSyncNode(*url, &changes); 144 CreateOrUpdateSyncNode(*url, &changes);
145 } 145 }
146 } 146 }
147 147
148 // Send SyncChangeList to server if there are any changes. 148 // Send SyncChangeList to server if there are any changes.
149 if (changes.size() > 0) 149 if (changes.size() > 0)
150 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 150 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
151 } 151 }
152 152
153 void TypedUrlSyncableService::OnUrlVisited(content::PageTransition transition, 153 void TypedUrlSyncableService::OnUrlVisited(content::PageTransition transition,
154 URLRow* row) { 154 URLRow* row) {
155 DCHECK(expected_loop_ == MessageLoop::current()); 155 DCHECK(expected_loop_ == base::MessageLoop::current());
156 DCHECK(row); 156 DCHECK(row);
157 157
158 if (processing_syncer_changes_) 158 if (processing_syncer_changes_)
159 return; // These are changes originating from us, ignore. 159 return; // These are changes originating from us, ignore.
160 if (!sync_processor_.get()) 160 if (!sync_processor_.get())
161 return; // Sync processor not yet initialized, don't sync. 161 return; // Sync processor not yet initialized, don't sync.
162 if (!ShouldSyncVisit(transition, row)) 162 if (!ShouldSyncVisit(transition, row))
163 return; 163 return;
164 164
165 // Create SyncChangeList. 165 // Create SyncChangeList.
166 syncer::SyncChangeList changes; 166 syncer::SyncChangeList changes;
167 167
168 CreateOrUpdateSyncNode(*row, &changes); 168 CreateOrUpdateSyncNode(*row, &changes);
169 169
170 // Send SyncChangeList to server if there are any changes. 170 // Send SyncChangeList to server if there are any changes.
171 if (changes.size() > 0) 171 if (changes.size() > 0)
172 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 172 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
173 } 173 }
174 174
175 void TypedUrlSyncableService::OnUrlsDeleted(bool all_history, 175 void TypedUrlSyncableService::OnUrlsDeleted(bool all_history,
176 bool archived, 176 bool archived,
177 URLRows* rows) { 177 URLRows* rows) {
178 DCHECK(expected_loop_ == MessageLoop::current()); 178 DCHECK(expected_loop_ == base::MessageLoop::current());
179 179
180 if (processing_syncer_changes_) 180 if (processing_syncer_changes_)
181 return; // These are changes originating from us, ignore. 181 return; // These are changes originating from us, ignore.
182 if (!sync_processor_.get()) 182 if (!sync_processor_.get())
183 return; // Sync processor not yet initialized, don't sync. 183 return; // Sync processor not yet initialized, don't sync.
184 184
185 // Ignore archivals (we don't want to sync them as deletions, to avoid 185 // Ignore archivals (we don't want to sync them as deletions, to avoid
186 // extra traffic up to the server, and also to make sure that a client with 186 // extra traffic up to the server, and also to make sure that a client with
187 // a bad clock setting won't go on an archival rampage and delete all 187 // a bad clock setting won't go on an archival rampage and delete all
188 // history from every client). The server will gracefully age out the sync DB 188 // history from every client). The server will gracefully age out the sync DB
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 // Sometimes, the last_visit field in the URL doesn't match the timestamp of 436 // Sometimes, the last_visit field in the URL doesn't match the timestamp of
437 // the last visit in our visit array (they come from different tables, so 437 // the last visit in our visit array (they come from different tables, so
438 // crashes/bugs can cause them to mismatch), so just set it here. 438 // crashes/bugs can cause them to mismatch), so just set it here.
439 url->set_last_visit(visits->back().visit_time); 439 url->set_last_visit(visits->back().visit_time);
440 DCHECK(CheckVisitOrdering(*visits)); 440 DCHECK(CheckVisitOrdering(*visits));
441 return true; 441 return true;
442 } 442 }
443 443
444 } // namespace history 444 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites_likely_impl_unittest.cc ('k') | chrome/browser/importer/firefox_importer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698