navigation_task_id.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2019 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_SESSIONS_CONTENT_NAVIGATION_TASK_ID_H_
  5. #define COMPONENTS_SESSIONS_CONTENT_NAVIGATION_TASK_ID_H_
  6. #include <stdint.h>
  7. #include "base/supports_user_data.h"
  8. #include "components/sessions/core/sessions_export.h"
  9. namespace content {
  10. class NavigationEntry;
  11. }
  12. namespace sessions {
  13. // Stores Task ID data in a NavigationEntry. Task IDs track navigations and
  14. // relationships between navigations
  15. class SESSIONS_EXPORT NavigationTaskId : public base::SupportsUserData::Data {
  16. public:
  17. NavigationTaskId();
  18. NavigationTaskId(const NavigationTaskId& navigation_task_id);
  19. ~NavigationTaskId() override;
  20. static NavigationTaskId* Get(content::NavigationEntry* entry);
  21. int64_t id() const { return id_; }
  22. int64_t parent_id() const { return parent_id_; }
  23. int64_t root_id() const { return root_id_; }
  24. void set_id(int64_t id) { id_ = id; }
  25. void set_parent_id(int64_t parent_id) { parent_id_ = parent_id; }
  26. void set_root_id(int64_t root_id) { root_id_ = root_id; }
  27. // base::SupportsUserData::Data:
  28. std::unique_ptr<base::SupportsUserData::Data> Clone() override;
  29. private:
  30. // A Task is a collection of navigations.
  31. //
  32. // A Task ID is an identifier of a Task. It is a Unique ID upon the first
  33. // navigation - navigating via the back button will not create a new ID but
  34. // the ID upon the first navigation will be used.
  35. //
  36. // A Parent Task ID is the identifier for the previous task in a series of
  37. // navigations.
  38. //
  39. // A Root Task ID is the first Task ID in a collection of navigations. Root
  40. // Task IDs are tracked for task clustering in the event that an intermediate
  41. // Tab is closed. It is not possible to group the tasks via a tree traversal
  42. // in this situation.
  43. int64_t id_ = -1;
  44. int64_t parent_id_ = -1;
  45. int64_t root_id_ = -1;
  46. };
  47. } // namespace sessions
  48. #endif // COMPONENTS_SESSIONS_CONTENT_NAVIGATION_TASK_ID_H_