chrome源码之恢复上次打开的标签页的学习

startup_browser_creator_impl.cc

————————》打开任何页面或浏览器的入口函数
bool StartupBrowserCreatorImpl::ProcessStartupURLs(const std::vector<GURL>& urls_to_open)
————————》
Browser* browser = SessionRestore::RestoreSession(profile_, NULL, restore_behavior, adjusted_urls);
————————》session_restore.cc
Browser* SessionRestore::RestoreSession(Profile* profile,Browser* browser,uint32_t behavior,const std::vector<GURL>& urls_to_open)
————————》
  Browser* Restore()
————————》
  void OnGotSession(std::vector<std::unique_ptr<sessions::SessionWindow>> windows,SessionID::id_type active_window_id)
————————》
  Browser* ProcessSessionWindowsAndNotify(std::vector<std::unique_ptr<sessions::SessionWindow>>* windows,SessionID::id_type active_window_id)
————————》
  Browser* ProcessSessionWindows(std::vector<std::unique_ptr<sessions::SessionWindow>>* windows,SessionID::id_type active_window_id,std::vector<RestoredTab>* created_contents)
————————》在以下函数中将上次的标签页存储到created_contents中并通过RestoreTab一一保存      
—》RestoreTabsToBrowser(*(*i), browser, initial_tab_count,selected_tab_index, created_contents);——》WebContents* contents = RestoreTab(tab, i, browser, is_selected_tab);
        
—》Browser* finished_browser = FinishedTabCreation(true, has_tabbed_browser, created_contents);
————————》之后是将上次保存的标签页全部打开
Browser* FinishedTabCreation(bool succeeded,bool created_tabbed_browser,std::vector<RestoredTab>* contents_created)
————————》session_restore_delegate.cc
SessionRestoreDelegate::RestoreTabs(*contents_created, restore_started_);
————————》
void SessionRestoreDelegate::RestoreTabs(const std::vector<RestoredTab>& tabs,const base::TimeTicks& restore_started)
————————》
void TabLoader::RestoreTabs(const std::vector<RestoredTab>& tabs,const base::TimeTicks& restore_started)


1.首次正常打开
Restore——》ProcessSessionWindowsAndNotify(Restore中调用)——》ProcessSessionWindows——》RestoreTabsToBrowser——》RestoreTab——》FinishedTabCreation——》RestoreTabs
2.非首次正常打开(之前有正常关闭的标签页)
Restore——》ProcessSessionWindowsAndNotify(Restore中调用)——》ProcessSessionWindows——》RestoreTabsToBrowser——》RestoreTab(n个:n为之前打开的标签页个数)——》FinishedTabCreation——》RestoreTabs
3.非首次非正常打开(之前有未正常关闭的标签页)
Restore——》OnGotSession——》ProcessSessionWindowsAndNotify(OnGotSession中调用)——》ProcessSessionWindows——》RestoreTabsToBrowser——》RestoreTab(n个:n为之前打开的标签页个数)——》FinishedTabCreation——》RestoreTabs

posted on 2017-03-31 13:42  P妞酱儿  阅读(351)  评论(0编辑  收藏  举报

导航