| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 class WriteTransaction; | 35 class WriteTransaction; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 namespace browser_sync { | 38 namespace browser_sync { |
| 39 | 39 |
| 40 // Contains all model association related logic: | 40 // Contains all model association related logic: |
| 41 // * Algorithm to associate typed_url model and sync model. | 41 // * Algorithm to associate typed_url model and sync model. |
| 42 // * Persisting model associations and loading them back. | 42 // * Persisting model associations and loading them back. |
| 43 // We do not check if we have local data before this run; we always | 43 // We do not check if we have local data before this run; we always |
| 44 // merge and sync. | 44 // merge and sync. |
| 45 class TypedUrlModelAssociator : public AssociatorInterface { | 45 class TypedUrlModelAssociator : public sync_driver::AssociatorInterface { |
| 46 public: | 46 public: |
| 47 typedef std::vector<std::pair<GURL, std::vector<history::VisitInfo> > > | 47 typedef std::vector<std::pair<GURL, std::vector<history::VisitInfo> > > |
| 48 TypedUrlVisitVector; | 48 TypedUrlVisitVector; |
| 49 | 49 |
| 50 static syncer::ModelType model_type() { return syncer::TYPED_URLS; } | 50 static syncer::ModelType model_type() { return syncer::TYPED_URLS; } |
| 51 TypedUrlModelAssociator(ProfileSyncService* sync_service, | 51 TypedUrlModelAssociator(ProfileSyncService* sync_service, |
| 52 history::HistoryBackend* history_backend, | 52 history::HistoryBackend* history_backend, |
| 53 DataTypeErrorHandler* error_handler); | 53 sync_driver::DataTypeErrorHandler* error_handler); |
| 54 virtual ~TypedUrlModelAssociator(); | 54 virtual ~TypedUrlModelAssociator(); |
| 55 | 55 |
| 56 // AssociatorInterface implementation. | 56 // AssociatorInterface implementation. |
| 57 // | 57 // |
| 58 // Iterates through the sync model looking for matched pairs of items. | 58 // Iterates through the sync model looking for matched pairs of items. |
| 59 virtual syncer::SyncError AssociateModels( | 59 virtual syncer::SyncError AssociateModels( |
| 60 syncer::SyncMergeResult* local_merge_result, | 60 syncer::SyncMergeResult* local_merge_result, |
| 61 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; | 61 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; |
| 62 | 62 |
| 63 // Clears all associations. | 63 // Clears all associations. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 bool ShouldIgnoreVisits(const history::VisitVector& visits); | 181 bool ShouldIgnoreVisits(const history::VisitVector& visits); |
| 182 | 182 |
| 183 ProfileSyncService* sync_service_; | 183 ProfileSyncService* sync_service_; |
| 184 history::HistoryBackend* history_backend_; | 184 history::HistoryBackend* history_backend_; |
| 185 | 185 |
| 186 base::MessageLoop* expected_loop_; | 186 base::MessageLoop* expected_loop_; |
| 187 | 187 |
| 188 bool abort_requested_; | 188 bool abort_requested_; |
| 189 base::Lock abort_lock_; | 189 base::Lock abort_lock_; |
| 190 | 190 |
| 191 DataTypeErrorHandler* error_handler_; // Guaranteed to outlive datatypes. | 191 // Guaranteed to outlive datatypes. |
| 192 sync_driver::DataTypeErrorHandler* error_handler_; |
| 192 | 193 |
| 193 // Statistics for the purposes of tracking the percentage of DB accesses that | 194 // Statistics for the purposes of tracking the percentage of DB accesses that |
| 194 // fail for each client via UMA. | 195 // fail for each client via UMA. |
| 195 int num_db_accesses_; | 196 int num_db_accesses_; |
| 196 int num_db_errors_; | 197 int num_db_errors_; |
| 197 | 198 |
| 198 DISALLOW_COPY_AND_ASSIGN(TypedUrlModelAssociator); | 199 DISALLOW_COPY_AND_ASSIGN(TypedUrlModelAssociator); |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 } // namespace browser_sync | 202 } // namespace browser_sync |
| 202 | 203 |
| 203 #endif // CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ | 204 #endif // CHROME_BROWSER_SYNC_GLUE_TYPED_URL_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |