state_serializer.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2012 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. //
  5. #ifndef ANDROID_WEBVIEW_BROWSER_STATE_SERIALIZER_H_
  6. #define ANDROID_WEBVIEW_BROWSER_STATE_SERIALIZER_H_
  7. #include <cstdint>
  8. namespace base {
  9. class Pickle;
  10. class PickleIterator;
  11. } // namespace base
  12. namespace content {
  13. class NavigationEntry;
  14. class NavigationEntryRestoreContext;
  15. class WebContents;
  16. } // namespace content
  17. namespace android_webview {
  18. // Write and restore a WebContents to and from a pickle. Return true on
  19. // success.
  20. // Note that |pickle| may be changed even if function returns false.
  21. void WriteToPickle(content::WebContents& web_contents, base::Pickle* pickle);
  22. // |web_contents| will not be modified if function returns false.
  23. [[nodiscard]] bool RestoreFromPickle(base::PickleIterator* iterator,
  24. content::WebContents* web_contents);
  25. namespace internal {
  26. const uint32_t AW_STATE_VERSION_INITIAL = 20130814;
  27. const uint32_t AW_STATE_VERSION_DATA_URL = 20151204;
  28. // Functions below are individual helper functions called by functions above.
  29. // They are broken up for unit testing, and should not be called out side of
  30. // tests.
  31. void WriteHeaderToPickle(base::Pickle* pickle);
  32. void WriteHeaderToPickle(uint32_t state_version, base::Pickle* pickle);
  33. [[nodiscard]] uint32_t RestoreHeaderFromPickle(base::PickleIterator* iterator);
  34. [[nodiscard]] bool IsSupportedVersion(uint32_t state_version);
  35. void WriteNavigationEntryToPickle(content::NavigationEntry& entry,
  36. base::Pickle* pickle);
  37. void WriteNavigationEntryToPickle(uint32_t state_version,
  38. content::NavigationEntry& entry,
  39. base::Pickle* pickle);
  40. [[nodiscard]] bool RestoreNavigationEntryFromPickle(
  41. base::PickleIterator* iterator,
  42. content::NavigationEntry* entry,
  43. content::NavigationEntryRestoreContext* context);
  44. [[nodiscard]] bool RestoreNavigationEntryFromPickle(
  45. uint32_t state_version,
  46. base::PickleIterator* iterator,
  47. content::NavigationEntry* entry,
  48. content::NavigationEntryRestoreContext* context);
  49. } // namespace internal
  50. } // namespace android_webview
  51. #endif // ANDROID_WEBVIEW_BROWSER_STATE_SERIALIZER_H_