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

Side by Side Diff: components/sessions/core/serialized_navigation_driver.h

Issue 2310363002: Persist offline page info in a navigation entry if needed (Closed)
Patch Set: Add extended info support Created 4 years, 2 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERIALIZED_NAVIGATION_DRIVER_H_ 5 #ifndef COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
6 #define COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_ 6 #define COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "components/sessions/core/sessions_export.h" 11 #include "components/sessions/core/sessions_export.h"
11 12
13 namespace content {
14 class NavigationEntry;
15 }
16
12 namespace sessions { 17 namespace sessions {
13 18
14 class SerializedNavigationEntry; 19 class SerializedNavigationEntry;
15 20
16 // The SerializedNavigationDriver interface allows SerializedNavigationEntry to 21 // The SerializedNavigationDriver interface allows SerializedNavigationEntry to
17 // obtain information from a singleton driver object. A concrete implementation 22 // obtain information from a singleton driver object. A concrete implementation
18 // must be provided by the driver on each platform. 23 // must be provided by the driver on each platform.
19 class SESSIONS_EXPORT SerializedNavigationDriver { 24 class SESSIONS_EXPORT SerializedNavigationDriver {
sky 2016/09/27 22:30:27 This code can't depend upon content. Your changes
jianli 2016/09/27 23:30:32 Done.
20 public: 25 public:
26 // The interface that handles how the extended info is converted betweened the
sky 2016/09/27 22:30:27 How about: This interface is used to store and ret
jianli 2016/09/27 23:30:32 Done.
27 // one stored in SerializedNavigationEntry and the one used in
28 // NavigationEntry.
29 class SESSIONS_EXPORT ExtendedInfoHandler {
sky 2016/09/27 22:30:27 Move this into it's own header.
jianli 2016/09/27 23:30:32 Done.
30 public:
31 virtual ~ExtendedInfoHandler() {}
32
33 // Returns the extended info from NavigationEntry for
34 // SerializedNavigationEntry to save it.
35 virtual std::string GetExtendedInfo(
36 const content::NavigationEntry& entry) const = 0;
37
38 // Puts the extended info, extracted from SerializedNavigationEntry, into
39 // NavigationEntry.
40 virtual void RestoreExtendedInfo(
41 const std::string& info, content::NavigationEntry* entry) = 0;
42 };
43
21 virtual ~SerializedNavigationDriver() {} 44 virtual ~SerializedNavigationDriver() {}
22 45
23 // Returns the singleton SerializedNavigationDriver. 46 // Returns the singleton SerializedNavigationDriver.
24 static SerializedNavigationDriver* Get(); 47 static SerializedNavigationDriver* Get();
25 48
26 // Returns the default referrer policy. 49 // Returns the default referrer policy.
27 virtual int GetDefaultReferrerPolicy() const = 0; 50 virtual int GetDefaultReferrerPolicy() const = 0;
28 51
29 // Maps current referrer policies to old values to work around 52 // Maps current referrer policies to old values to work around
30 // crbug.com/450589. Returns false if the referrer should be stripped. 53 // crbug.com/450589. Returns false if the referrer should be stripped.
(...skipping 12 matching lines...) Expand all
43 virtual std::string GetSanitizedPageStateForPickle( 66 virtual std::string GetSanitizedPageStateForPickle(
44 const SerializedNavigationEntry* navigation) const = 0; 67 const SerializedNavigationEntry* navigation) const = 0;
45 68
46 // Sanitizes the data in the given |navigation| to be more robust against 69 // Sanitizes the data in the given |navigation| to be more robust against
47 // faulty data written by older versions. 70 // faulty data written by older versions.
48 virtual void Sanitize(SerializedNavigationEntry* navigation) const = 0; 71 virtual void Sanitize(SerializedNavigationEntry* navigation) const = 0;
49 72
50 // Removes the referrer from the encoded page state. 73 // Removes the referrer from the encoded page state.
51 virtual std::string StripReferrerFromPageState( 74 virtual std::string StripReferrerFromPageState(
52 const std::string& page_state) const = 0; 75 const std::string& page_state) const = 0;
76
77 // Registers a handler that could be used to read and write the extended
sky 2016/09/27 22:30:27 'could be' -> is
jianli 2016/09/27 23:30:32 Done.
78 // info stored in SerializedNavigationEntry.
79 virtual void RegisterExtendedInfoHandler(
80 const std::string& key,
81 std::unique_ptr<ExtendedInfoHandler> handler) = 0;
82
83 typedef std::map<std::string, std::unique_ptr<ExtendedInfoHandler>>
sky 2016/09/27 22:30:27 using.
jianli 2016/09/27 23:30:32 Done.
84 ExtendedInfoHandlerMap;
85
86 // Returns all the registered handlers to deal with the extended info.
87 virtual const ExtendedInfoHandlerMap& GetAllExtendedInfoHandlers() const = 0;
53 }; 88 };
54 89
55 } // namespace sessions 90 } // namespace sessions
56 91
57 #endif // COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_ 92 #endif // COMPONENTS_SESSIONS_CORE_SERIALIZED_NAVIGATION_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698