sessions_global_id_mapper.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_SESSIONS_SESSIONS_GLOBAL_ID_MAPPER_H_
  5. #define COMPONENTS_SYNC_SESSIONS_SESSIONS_GLOBAL_ID_MAPPER_H_
  6. #include <map>
  7. #include <vector>
  8. #include "base/time/time.h"
  9. #include "components/sync_user_events/global_id_mapper.h"
  10. namespace sync_sessions {
  11. // Actual implementation of GlobalIdMapper used by sessions.
  12. class SessionsGlobalIdMapper : public syncer::GlobalIdMapper {
  13. public:
  14. SessionsGlobalIdMapper();
  15. SessionsGlobalIdMapper(const SessionsGlobalIdMapper&) = delete;
  16. SessionsGlobalIdMapper& operator=(const SessionsGlobalIdMapper&) = delete;
  17. ~SessionsGlobalIdMapper();
  18. // GlobalIdMapper implementation.
  19. void AddGlobalIdChangeObserver(syncer::GlobalIdChange callback) override;
  20. int64_t GetLatestGlobalId(int64_t global_id) override;
  21. void TrackNavigationId(const base::Time& timestamp, int unique_id);
  22. private:
  23. void CleanupNavigationTracking();
  24. std::map<int64_t, int> global_to_unique_;
  25. std::map<int, int64_t> unique_to_current_global_;
  26. std::vector<syncer::GlobalIdChange> global_id_change_observers_;
  27. };
  28. } // namespace sync_sessions
  29. #endif // COMPONENTS_SYNC_SESSIONS_SESSIONS_GLOBAL_ID_MAPPER_H_