OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ | 5 #ifndef COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ |
6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ | 6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/trace_event/memory_dump_provider.h" |
14 #include "components/sessions/core/session_id.h" | 15 #include "components/sessions/core/session_id.h" |
15 #include "components/sessions/core/session_types.h" | 16 #include "components/sessions/core/session_types.h" |
16 #include "components/sessions/core/sessions_export.h" | 17 #include "components/sessions/core/sessions_export.h" |
17 #include "components/sessions/core/tab_restore_service.h" | 18 #include "components/sessions/core/tab_restore_service.h" |
18 | 19 |
19 namespace sessions { | 20 namespace sessions { |
20 | 21 |
21 class TabRestoreService; | 22 class TabRestoreService; |
22 class TabRestoreServiceClient; | 23 class TabRestoreServiceClient; |
23 class LiveTabContext; | 24 class LiveTabContext; |
24 class TabRestoreServiceObserver; | 25 class TabRestoreServiceObserver; |
25 class TimeFactory; | 26 class TimeFactory; |
26 | 27 |
27 // Helper class used to implement InMemoryTabRestoreService and | 28 // Helper class used to implement InMemoryTabRestoreService and |
28 // PersistentTabRestoreService. See tab_restore_service.h for method-level | 29 // PersistentTabRestoreService. See tab_restore_service.h for method-level |
29 // comments. | 30 // comments. |
30 class SESSIONS_EXPORT TabRestoreServiceHelper { | 31 class SESSIONS_EXPORT TabRestoreServiceHelper |
| 32 : public base::trace_event::MemoryDumpProvider { |
31 public: | 33 public: |
32 typedef TabRestoreService::Entries Entries; | 34 typedef TabRestoreService::Entries Entries; |
33 typedef TabRestoreService::Entry Entry; | 35 typedef TabRestoreService::Entry Entry; |
34 typedef TabRestoreService::Tab Tab; | 36 typedef TabRestoreService::Tab Tab; |
35 typedef TabRestoreService::TimeFactory TimeFactory; | 37 typedef TabRestoreService::TimeFactory TimeFactory; |
36 typedef TabRestoreService::Window Window; | 38 typedef TabRestoreService::Window Window; |
37 | 39 |
38 // Provides a way for the client to add behavior to the tab restore service | 40 // Provides a way for the client to add behavior to the tab restore service |
39 // helper (e.g. implementing tabs persistence). | 41 // helper (e.g. implementing tabs persistence). |
40 class Observer { | 42 class Observer { |
(...skipping 19 matching lines...) Expand all Loading... |
60 }; | 62 }; |
61 | 63 |
62 // Creates a new TabRestoreServiceHelper and provides an object that provides | 64 // Creates a new TabRestoreServiceHelper and provides an object that provides |
63 // the current time. The TabRestoreServiceHelper does not take ownership of | 65 // the current time. The TabRestoreServiceHelper does not take ownership of |
64 // |time_factory| and |observer|. Note that |observer| can also be NULL. | 66 // |time_factory| and |observer|. Note that |observer| can also be NULL. |
65 TabRestoreServiceHelper(TabRestoreService* tab_restore_service, | 67 TabRestoreServiceHelper(TabRestoreService* tab_restore_service, |
66 Observer* observer, | 68 Observer* observer, |
67 TabRestoreServiceClient* client, | 69 TabRestoreServiceClient* client, |
68 TimeFactory* time_factory); | 70 TimeFactory* time_factory); |
69 | 71 |
70 ~TabRestoreServiceHelper(); | 72 ~TabRestoreServiceHelper() override; |
71 | 73 |
72 // Helper methods used to implement TabRestoreService. | 74 // Helper methods used to implement TabRestoreService. |
73 void AddObserver(TabRestoreServiceObserver* observer); | 75 void AddObserver(TabRestoreServiceObserver* observer); |
74 void RemoveObserver(TabRestoreServiceObserver* observer); | 76 void RemoveObserver(TabRestoreServiceObserver* observer); |
75 void CreateHistoricalTab(LiveTab* live_tab, int index); | 77 void CreateHistoricalTab(LiveTab* live_tab, int index); |
76 void BrowserClosing(LiveTabContext* context); | 78 void BrowserClosing(LiveTabContext* context); |
77 void BrowserClosed(LiveTabContext* context); | 79 void BrowserClosed(LiveTabContext* context); |
78 void ClearEntries(); | 80 void ClearEntries(); |
79 const Entries& entries() const; | 81 const Entries& entries() const; |
80 std::vector<LiveTab*> RestoreMostRecentEntry(LiveTabContext* context); | 82 std::vector<LiveTab*> RestoreMostRecentEntry(LiveTabContext* context); |
(...skipping 18 matching lines...) Expand all Loading... |
99 // Prunes |entries_| to contain only kMaxEntries, and removes uninteresting | 101 // Prunes |entries_| to contain only kMaxEntries, and removes uninteresting |
100 // entries. | 102 // entries. |
101 void PruneEntries(); | 103 void PruneEntries(); |
102 | 104 |
103 // Returns an iterator into |entries_| whose id matches |id|. If |id| | 105 // Returns an iterator into |entries_| whose id matches |id|. If |id| |
104 // identifies a Window, then its iterator position will be returned. If it | 106 // identifies a Window, then its iterator position will be returned. If it |
105 // identifies a tab, then the iterator position of the Window in which the Tab | 107 // identifies a tab, then the iterator position of the Window in which the Tab |
106 // resides is returned. | 108 // resides is returned. |
107 Entries::iterator GetEntryIteratorById(SessionID::id_type id); | 109 Entries::iterator GetEntryIteratorById(SessionID::id_type id); |
108 | 110 |
| 111 // From base::trace_event::MemoryDumpProvider |
| 112 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 113 base::trace_event::ProcessMemoryDump* pmd) override; |
| 114 |
109 // Calls either ValidateTab or ValidateWindow as appropriate. | 115 // Calls either ValidateTab or ValidateWindow as appropriate. |
110 static bool ValidateEntry(const Entry& entry); | 116 static bool ValidateEntry(const Entry& entry); |
111 | 117 |
112 private: | 118 private: |
113 friend class PersistentTabRestoreService; | 119 friend class PersistentTabRestoreService; |
114 | 120 |
115 // Populates the tab's navigations from the LiveTab, and its browser_id and | 121 // Populates the tab's navigations from the LiveTab, and its browser_id and |
116 // pinned state from the context. | 122 // pinned state from the context. |
117 void PopulateTab(Tab* tab, | 123 void PopulateTab(Tab* tab, |
118 int index, | 124 int index, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 std::set<LiveTabContext*> closing_contexts_; | 182 std::set<LiveTabContext*> closing_contexts_; |
177 | 183 |
178 TimeFactory* const time_factory_; | 184 TimeFactory* const time_factory_; |
179 | 185 |
180 DISALLOW_COPY_AND_ASSIGN(TabRestoreServiceHelper); | 186 DISALLOW_COPY_AND_ASSIGN(TabRestoreServiceHelper); |
181 }; | 187 }; |
182 | 188 |
183 } // namespace sessions | 189 } // namespace sessions |
184 | 190 |
185 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ | 191 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_HELPER_H_ |
OLD | NEW |