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

Side by Side Diff: ios/web/public/serializable_user_data_manager.h

Issue 2687353003: Created SerializableUserDataManager. (Closed)
Patch Set: Eugene's comments Created 3 years, 10 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
(Empty)
1 // Copyright 2017 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 IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
6 #define IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
7
8 #import <Foundation/Foundation.h>
9 #include <memory>
10
11 namespace web {
12
13 class WebState;
14
15 // Class used to serialize values added to SerializableUserDataManager.
16 class SerializableUserData {
17 public:
18 // Factory method.
19 static std::unique_ptr<SerializableUserData> Create();
20
21 // Encodes the data with |coder|.
22 virtual void Encode(NSCoder* coder) = 0;
23
24 // Decodes the data from |coder|.
25 virtual void Decode(NSCoder* coder) = 0;
26 };
27
28 // Class that can be used to add serializable user data to a WebState.
29 class SerializableUserDataManager {
30 public:
31 // Returns the SerializableUserDataManager instance associated with
32 // |web_state|, instantiating one if necessary.
33 static SerializableUserDataManager* FromWebState(web::WebState* web_state);
34
35 // Adds |data| to the user data, allowing it to be encoded under |key|.
36 // |data| is expected to be non-nil. If |key| has already been used, its
37 // associated value will be overwritten.
38 virtual void AddSerializableData(id<NSCoding> data, NSString* key) = 0;
39
40 // Returns the value that has been stored under |key|.
41 virtual id<NSCoding> GetValueForSerializationKey(NSString* key) = 0;
42
43 // Creates a SerializableUserData that can be used to encode the values added
44 // to the manager.
45 virtual std::unique_ptr<SerializableUserData> CreateSerializableUserData()
46 const = 0;
47
48 // Adds the values decoded from |data| to the manager.
49 virtual void AddSerializableUserData(SerializableUserData* data) = 0;
50 };
51
52 } // namespace web
53
54 #endif // IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « ios/web/public/crw_session_storage.mm ('k') | ios/web/public/serializable_user_data_manager_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698