minimal_browser_persister.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef WEBLAYER_BROWSER_PERSISTENCE_MINIMAL_BROWSER_PERSISTER_H_
  5. #define WEBLAYER_BROWSER_PERSISTENCE_MINIMAL_BROWSER_PERSISTER_H_
  6. #include <stddef.h>
  7. #include <vector>
  8. namespace weblayer {
  9. class BrowserImpl;
  10. // Returns a byte array that can later be used to restore the state (Tabs and
  11. // navigations) of a Browser. This does not store the full state, only a
  12. // minimal state. For example, it may not include all tabs or all navigations.
  13. // |max_navigations_per_tab| is the max number of navigations to persist per
  14. // tab. Depending upon space requirements, the max number of navigations may not
  15. // be honored. |max_size_in_bytes| is provided for tests and allows specifying
  16. // the max. A value of 0 means use the default max.
  17. std::vector<uint8_t> PersistMinimalState(BrowserImpl* browser,
  18. int max_navigations_per_tab = 0,
  19. int max_size_in_bytes = 0);
  20. // Restores the state previously created via PersistMinimalState(). When
  21. // done this ensures |browser| has at least one tab.
  22. void RestoreMinimalStateForBrowser(BrowserImpl* browser,
  23. const std::vector<uint8_t>& value);
  24. } // namespace weblayer
  25. #endif // WEBLAYER_BROWSER_PERSISTENCE_MINIMAL_BROWSER_PERSISTER_H_