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