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/typed_url_change_processor.h" | 5 #include "chrome/browser/sync/glue/typed_url_change_processor.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode( | 150 bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode( |
151 history::URLRow url, syncer::WriteTransaction* trans) { | 151 history::URLRow url, syncer::WriteTransaction* trans) { |
152 DCHECK_GE(url.typed_count(), 0); | 152 DCHECK_GE(url.typed_count(), 0); |
153 // Get the visits for this node. | 153 // Get the visits for this node. |
154 history::VisitVector visit_vector; | 154 history::VisitVector visit_vector; |
155 if (!model_associator_->FixupURLAndGetVisits(&url, &visit_vector)) { | 155 if (!model_associator_->FixupURLAndGetVisits(&url, &visit_vector)) { |
156 DLOG(ERROR) << "Could not load visits for url: " << url.url(); | 156 DLOG(ERROR) << "Could not load visits for url: " << url.url(); |
157 return false; | 157 return false; |
158 } | 158 } |
159 | 159 |
160 if (std::find_if(visit_vector.begin(), visit_vector.end(), | |
161 [](const history::VisitRow& visit) { | |
162 return ui::PageTransitionCoreTypeIs( | |
163 visit.transition, ui::PAGE_TRANSITION_TYPED); | |
164 }) == visit_vector.end()) | |
165 // This URL has no TYPED visits, don't sync it. | |
166 return false; | |
167 | |
168 syncer::ReadNode typed_url_root(trans); | 160 syncer::ReadNode typed_url_root(trans); |
169 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != | 161 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != |
170 syncer::BaseNode::INIT_OK) { | 162 syncer::BaseNode::INIT_OK) { |
171 syncer::SyncError error(FROM_HERE, | 163 syncer::SyncError error(FROM_HERE, |
172 syncer::SyncError::DATATYPE_ERROR, | 164 syncer::SyncError::DATATYPE_ERROR, |
173 "No top level folder", | 165 "No top level folder", |
174 syncer::TYPED_URLS); | 166 syncer::TYPED_URLS); |
175 error_handler()->OnSingleDataTypeUnrecoverableError(error); | 167 error_handler()->OnSingleDataTypeUnrecoverableError(error); |
176 return false; | 168 return false; |
177 } | 169 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 339 } |
348 | 340 |
349 void TypedUrlChangeProcessor::StopObserving() { | 341 void TypedUrlChangeProcessor::StopObserving() { |
350 DCHECK(backend_loop_ == base::MessageLoop::current()); | 342 DCHECK(backend_loop_ == base::MessageLoop::current()); |
351 DCHECK(history_backend_); | 343 DCHECK(history_backend_); |
352 DCHECK(profile_); | 344 DCHECK(profile_); |
353 history_backend_observer_.RemoveAll(); | 345 history_backend_observer_.RemoveAll(); |
354 } | 346 } |
355 | 347 |
356 } // namespace browser_sync | 348 } // namespace browser_sync |
OLD | NEW |