Chromium Code Reviews| 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(), | |
|
maniscalco
2015/05/08 19:38:00
Question about performance. How big does visit_ve
mpawlowski
2015/05/11 09:27:18
Good point, I've checked with an old profile with
| |
| 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 | |
| 160 syncer::ReadNode typed_url_root(trans); | 168 syncer::ReadNode typed_url_root(trans); |
| 161 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != | 169 if (typed_url_root.InitTypeRoot(syncer::TYPED_URLS) != |
| 162 syncer::BaseNode::INIT_OK) { | 170 syncer::BaseNode::INIT_OK) { |
| 163 syncer::SyncError error(FROM_HERE, | 171 syncer::SyncError error(FROM_HERE, |
| 164 syncer::SyncError::DATATYPE_ERROR, | 172 syncer::SyncError::DATATYPE_ERROR, |
| 165 "No top level folder", | 173 "No top level folder", |
| 166 syncer::TYPED_URLS); | 174 syncer::TYPED_URLS); |
| 167 error_handler()->OnSingleDataTypeUnrecoverableError(error); | 175 error_handler()->OnSingleDataTypeUnrecoverableError(error); |
| 168 return false; | 176 return false; |
| 169 } | 177 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 } | 347 } |
| 340 | 348 |
| 341 void TypedUrlChangeProcessor::StopObserving() { | 349 void TypedUrlChangeProcessor::StopObserving() { |
| 342 DCHECK(backend_loop_ == base::MessageLoop::current()); | 350 DCHECK(backend_loop_ == base::MessageLoop::current()); |
| 343 DCHECK(history_backend_); | 351 DCHECK(history_backend_); |
| 344 DCHECK(profile_); | 352 DCHECK(profile_); |
| 345 history_backend_observer_.RemoveAll(); | 353 history_backend_observer_.RemoveAll(); |
| 346 } | 354 } |
| 347 | 355 |
| 348 } // namespace browser_sync | 356 } // namespace browser_sync |
| OLD | NEW |