Index: components/sync_sessions/task_tracker.h |
diff --git a/components/sync_sessions/task_tracker.h b/components/sync_sessions/task_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9e3321656f4f678ecd7afb841eb13ea0ca5cc61d |
--- /dev/null |
+++ b/components/sync_sessions/task_tracker.h |
@@ -0,0 +1,61 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_ |
+#define COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_ |
+ |
+#include <stddef.h> |
+ |
+#include <map> |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/time/time.h" |
+#include "components/sessions/core/session_id.h" |
+#include "components/sessions/core/session_types.h" |
+#include "components/sync_sessions/synced_tab_delegate.h" |
+#include "ui/base/page_transition_types.h" |
+ |
+namespace sync_sessions { |
+ |
+// Tracks tasks of a tab. |
Patrick Noland
2017/03/24 20:51:57
Can you expand this comment? It's not currently ex
shenchao
2017/03/25 23:53:13
Done.
|
+class TabTasks { |
+ public: |
+ TabTasks(); |
+ virtual ~TabTasks(); |
+ |
+ // Return task id as a vector of int64_t for |nav_index|-th navigation of the |
+ // tab. |
+ std::vector<int64_t> GetTaskIdAtNav(int nav_index) const; |
Patrick Noland
2017/03/24 20:51:57
AtIndex or at AtNavIndex would be more descriptive
shenchao
2017/03/25 23:53:13
Done.
|
+ |
+ int GetNavigationsNum() const { return ids_.size(); } |
Patrick Noland
2017/03/24 20:51:57
count or size would be more descriptive than Num
shenchao
2017/03/25 23:53:13
Done.
|
+ |
+ // Updates the current task of the tab, given current navigation index of the |
+ // tab as |current_nav_index|, and its transition |current_nav_transition|. If |
+ // a new task is created, its id is (its parent task id, |new_id|). |
+ void UpdateTask(int current_nav_index, |
+ ui::PageTransition current_nav_transition, |
+ int64_t new_id); |
Patrick Noland
2017/03/24 20:51:57
I'm a little confused that new_id is supplied as a
shenchao
2017/03/25 23:53:13
Done. I did that to make test easy but agree it wa
|
+ |
+ private: |
+ std::vector<int64_t> ids_; |
+ int current_task_index_ = -1; |
+}; |
+ |
+// Tracks tasks of current session. |
+class TaskTracker { |
+ public: |
+ TaskTracker(); |
+ virtual ~TaskTracker(); |
+ // Returns a TabTasks pointer, which is owned by this object, for the tab of |
+ // given |tab_id|. |
+ TabTasks* GetTabTasks(SessionID::id_type tab_id); |
+ |
+ private: |
+ std::map<SessionID::id_type, std::unique_ptr<TabTasks>> local_tab_tasks_map_; |
+}; |
+ |
+} // namespace sync_sessions |
+ |
+#endif // COMPONENTS_SYNC_SESSIONS_TASK_TRACKER_H_ |