| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ | 5 #ifndef COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ |
| 6 #define COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ | 6 #define COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/sessions/core/session_id.h" | 12 #include "components/sessions/core/session_id.h" |
| 13 #include "components/sync/model/local_change_observer.h" | 13 #include "components/sync/model/local_change_observer.h" |
| 14 #include "components/sync/model/sync_change.h" | 14 #include "components/sync/model/sync_change.h" |
| 15 #include "components/sync/protocol/session_specifics.pb.h" | 15 #include "components/sync/protocol/session_specifics.pb.h" |
| 16 | 16 |
| 17 namespace sync_sessions { | 17 namespace sync_sessions { |
| 18 | 18 |
| 19 // Recorder class that tracks the number of navigations written locally that | 19 // Recorder class that tracks the number of navigations written locally that |
| 20 // aren't synced. This is done by recording set of locally observed navigations | 20 // aren't synced. This is done by recording set of locally observed navigations |
| 21 // and reconciling these sets against what was ultimately synced. These | 21 // and reconciling these sets against what was ultimately synced. These |
| 22 // navigations ultimately feed chrome history, so losing them prevents them from | 22 // navigations ultimately feed chrome history, so losing them prevents them from |
| 23 // being reflected in the history page. | 23 // being reflected in the history page. |
| 24 class LostNavigationsRecorder : public syncer::LocalChangeObserver { | 24 class LostNavigationsRecorder : public syncer::LocalChangeObserver { |
| 25 public: | 25 public: |
| 26 typedef SessionID::id_type id_type; | 26 using id_type = SessionID::id_type; |
| 27 typedef std::set<id_type> IdSet; | 27 using IdSet = std::set<id_type>; |
| 28 enum RecorderState { RECORDER_STATE_NOT_SYNCING, RECORDER_STATE_SYNCING }; | 28 enum RecorderState { RECORDER_STATE_NOT_SYNCING, RECORDER_STATE_SYNCING }; |
| 29 | 29 |
| 30 LostNavigationsRecorder(); | 30 LostNavigationsRecorder(); |
| 31 ~LostNavigationsRecorder() override; | 31 ~LostNavigationsRecorder() override; |
| 32 | 32 |
| 33 // syncer::LocalChangeObserver implementation. | 33 // syncer::LocalChangeObserver implementation. |
| 34 void OnLocalChange(const syncer::syncable::Entry* current_entry, | 34 void OnLocalChange(const syncer::syncable::Entry* current_entry, |
| 35 const syncer::SyncChange& change) override; | 35 const syncer::SyncChange& change) override; |
| 36 | 36 |
| 37 private: | 37 private: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 49 std::map<id_type, IdSet> recorded_navigation_ids_; | 49 std::map<id_type, IdSet> recorded_navigation_ids_; |
| 50 // The set of navigation ids most recently recorded for each tab_id. | 50 // The set of navigation ids most recently recorded for each tab_id. |
| 51 std::map<id_type, IdSet> latest_navigation_ids_; | 51 std::map<id_type, IdSet> latest_navigation_ids_; |
| 52 // The maximum navigation_id recorded for each tab_id. | 52 // The maximum navigation_id recorded for each tab_id. |
| 53 std::map<id_type, id_type> max_recorded_for_tab_; | 53 std::map<id_type, id_type> max_recorded_for_tab_; |
| 54 DISALLOW_COPY_AND_ASSIGN(LostNavigationsRecorder); | 54 DISALLOW_COPY_AND_ASSIGN(LostNavigationsRecorder); |
| 55 }; | 55 }; |
| 56 }; // namespace sync_sessions | 56 }; // namespace sync_sessions |
| 57 | 57 |
| 58 #endif // COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ | 58 #endif // COMPONENTS_SYNC_SESSIONS_LOST_NAVIGATIONS_RECORDER_H_ |
| OLD | NEW |