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

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

Issue 2687353003: Created SerializableUserDataManager. (Closed)
Patch Set: self review, added unittest 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
Eugene But (OOO till 7-30) 2017/02/11 02:46:48 Do you need to finish this sentence?
kkhorimoto 2017/02/11 03:19:49 whoops! yes I did!
37 virtual void AddSerializableData(id<NSCoding> data, NSString* key) = 0;
38
39 // Returns the value that has been stored under |key|.
40 virtual id<NSCoding> GetValueForSerializationKey(NSString* key) = 0;
41
42 // Creates a SerializableUserData that can be used to encode the values added
43 // to the manager.
44 virtual std::unique_ptr<SerializableUserData> CreateSerializableUserData()
45 const = 0;
46
47 // Adds the values decoded from |data| to the manager.
48 virtual void AddSerializableUserData(SerializableUserData* data) = 0;
49 };
50
51 } // namespace web
52
53 #endif // IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698