Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: components/sync_sessions/task_tracker.cc

Issue 2868043003: Track task ids for navigations cross multiple tabs. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync_sessions/task_tracker.cc
diff --git a/components/sync_sessions/task_tracker.cc b/components/sync_sessions/task_tracker.cc
index 0f8902e2905383a98113746e138927b4909e1d7c..6eb618e108585c70b2969a2a88e8d01d9a92c3ed 100644
--- a/components/sync_sessions/task_tracker.cc
+++ b/components/sync_sessions/task_tracker.cc
@@ -17,6 +17,13 @@ int kMaxNumTasksPerTab = 100;
TabTasks::TabTasks() {}
+TabTasks::TabTasks(const TabTasks* source_tab) {
+ if (source_tab->current_navigation_index_ >= 0) {
+ source_tab_task_ids_ = source_tab->GetTaskIdsForNavigation(
+ source_tab->current_navigation_index_);
+ }
+}
+
TabTasks::~TabTasks() {}
std::vector<int64_t> TabTasks::GetTaskIdsForNavigation(
@@ -44,6 +51,20 @@ std::vector<int64_t> TabTasks::GetTaskIdsForNavigation(
task_id_and_root.root_navigation_index > excluded_navigation_num_
? task_id_and_root.root_navigation_index - excluded_navigation_num_
: 0;
+ // Only consider tasks from source tab when no tasks in current tab is
+ // excluded because max number per tab limit.
+ if (excluded_navigation_num_ == 0) {
+ int first_task_of_tab_position = 0;
+ // skipping invalid heading tasks
+ for (; first_task_of_tab_position < navigation_position &&
+ task_ids_[first_task_of_tab_position].root_navigation_index < 0;
+ first_task_of_tab_position++) {
+ }
+ // If task of current navigation can track back to the first task of the
+ // tab, then consider the source tab.
+ if (task_id_and_root.root_navigation_index == first_task_of_tab_position)
+ root_to_self_task_ids = source_tab_task_ids_;
+ }
for (int i = root_navigation_index; i <= navigation_position; i++) {
// Fills the vector with valid tasks.
if (task_ids_[i].root_navigation_index >= 0)
@@ -163,6 +184,20 @@ TabTasks* TaskTracker::GetTabTasks(SessionID::id_type tab_id) {
return local_tab_tasks_map_[tab_id].get();
}
+TabTasks* TaskTracker::GetTabTasks(SessionID::id_type tab_id,
+ SessionID::id_type source_tab_id) {
+ if (local_tab_tasks_map_.find(tab_id) == local_tab_tasks_map_.end()) {
+ auto iter = local_tab_tasks_map_.find(source_tab_id);
+ if (iter != local_tab_tasks_map_.end()) {
+ local_tab_tasks_map_[tab_id] =
+ base::MakeUnique<TabTasks>(iter->second.get());
+ } else {
+ local_tab_tasks_map_[tab_id] = base::MakeUnique<TabTasks>();
+ }
+ }
+ return local_tab_tasks_map_[tab_id].get();
+}
+
void TaskTracker::CleanTabTasks(SessionID::id_type tab_id) {
auto iter = local_tab_tasks_map_.find(tab_id);
if (iter != local_tab_tasks_map_.end()) {

Powered by Google App Engine
This is Rietveld 408576698