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

Side by Side Diff: chrome/browser/sessions/tab_loader.h

Issue 2466883002: Add TabLoaderTest (Closed)
Patch Set: Use ScopedFeatureList Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
6 #define CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 6 #define CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 13
14 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/memory_coordinator_client.h" 16 #include "base/memory/memory_coordinator_client.h"
16 #include "base/memory/memory_pressure_listener.h" 17 #include "base/memory/memory_pressure_listener.h"
17 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
18 #include "chrome/browser/sessions/session_restore_delegate.h" 19 #include "chrome/browser/sessions/session_restore_delegate.h"
19 #include "chrome/browser/sessions/tab_loader_delegate.h" 20 #include "chrome/browser/sessions/tab_loader_delegate.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 23
23 namespace content { 24 namespace content {
24 class NavigationController; 25 class NavigationController;
25 class RenderWidgetHost; 26 class RenderWidgetHost;
26 } 27 }
27 28
28 class SessionRestoreStatsCollector; 29 class SessionRestoreStatsCollector;
30 class TabLoaderTest;
29 31
30 // TabLoader is responsible for loading tabs after session restore has finished 32 // TabLoader is responsible for loading tabs after session restore has finished
31 // creating all the tabs. Tabs are loaded after a previously tab finishes 33 // creating all the tabs. Tabs are loaded after a previously tab finishes
32 // loading or a timeout is reached. If the timeout is reached before a tab 34 // loading or a timeout is reached. If the timeout is reached before a tab
33 // finishes loading the timeout delay is doubled. 35 // finishes loading the timeout delay is doubled.
34 // 36 //
35 // TabLoader keeps a reference to itself when it's loading. When it has finished 37 // TabLoader keeps a reference to itself when it's loading. When it has finished
36 // loading, it drops the reference. If another profile is restored while the 38 // loading, it drops the reference. If another profile is restored while the
37 // TabLoader is loading, it will schedule its tabs to get loaded by the same 39 // TabLoader is loading, it will schedule its tabs to get loaded by the same
38 // TabLoader. When doing the scheduling, it holds a reference to the TabLoader. 40 // TabLoader. When doing the scheduling, it holds a reference to the TabLoader.
(...skipping 14 matching lines...) Expand all
53 const content::NotificationDetails& details) override; 55 const content::NotificationDetails& details) override;
54 56
55 // TabLoaderCallback: 57 // TabLoaderCallback:
56 void SetTabLoadingEnabled(bool enable_tab_loading) override; 58 void SetTabLoadingEnabled(bool enable_tab_loading) override;
57 59
58 // Called to start restoring tabs. 60 // Called to start restoring tabs.
59 static void RestoreTabs(const std::vector<RestoredTab>& tabs, 61 static void RestoreTabs(const std::vector<RestoredTab>& tabs,
60 const base::TimeTicks& restore_started); 62 const base::TimeTicks& restore_started);
61 63
62 private: 64 private:
65 FRIEND_TEST_ALL_PREFIXES(TabLoaderTest, OnMemoryStateChange);
66
63 friend class base::RefCounted<TabLoader>; 67 friend class base::RefCounted<TabLoader>;
64 68
65 using TabsLoading = std::set<content::NavigationController*>; 69 using TabsLoading = std::set<content::NavigationController*>;
66 using TabsToLoad = std::list<content::NavigationController*>; 70 using TabsToLoad = std::list<content::NavigationController*>;
67 71
68 explicit TabLoader(base::TimeTicks restore_started); 72 explicit TabLoader(base::TimeTicks restore_started);
69 ~TabLoader() override; 73 ~TabLoader() override;
70 74
71 // This is invoked once by RestoreTabs to start loading. 75 // This is invoked once by RestoreTabs to start loading.
72 void StartLoading(const std::vector<RestoredTab>& tabs); 76 void StartLoading(const std::vector<RestoredTab>& tabs);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // explicitly referenced so that it can be notified of deferred tab loads due 157 // explicitly referenced so that it can be notified of deferred tab loads due
154 // to memory pressure. 158 // to memory pressure.
155 scoped_refptr<SessionRestoreStatsCollector> stats_collector_; 159 scoped_refptr<SessionRestoreStatsCollector> stats_collector_;
156 160
157 static TabLoader* shared_tab_loader_; 161 static TabLoader* shared_tab_loader_;
158 162
159 DISALLOW_COPY_AND_ASSIGN(TabLoader); 163 DISALLOW_COPY_AND_ASSIGN(TabLoader);
160 }; 164 };
161 165
162 #endif // CHROME_BROWSER_SESSIONS_TAB_LOADER_H_ 166 #endif // CHROME_BROWSER_SESSIONS_TAB_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698