forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserializable_user_data_manager_impl.h
71 lines (54 loc) · 2.58 KB
/
serializable_user_data_manager_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_
#define IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_
#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#import "ios/web/public/serializable_user_data_manager.h"
namespace web {
class SerializableUserDataImpl : public SerializableUserData {
public:
SerializableUserDataImpl();
~SerializableUserDataImpl() override;
// Constructor taking the NSDictionary holding the serializable data.
explicit SerializableUserDataImpl(
NSDictionary<NSString*, id<NSCoding>>* data);
// SerializableUserData:
void Encode(NSCoder* coder) override;
void Decode(NSCoder* coder) override;
// Returns the serializable data.
NSDictionary<NSString*, id<NSCoding>>* data() { return data_; }
// Returns the dictionary mapping the key of value that used to be persisted
// directly in CRWSessionStorate to the corresponding key when serialised in
// SerializableUserData.
// TODO(crbug.com/691800): Remove legacy support.
static NSDictionary<NSString*, NSString*>* GetLegacyKeyConversion();
private:
// Decodes the values that were previously encoded using CRWSessionStorage's
// NSCoding implementation and returns an NSDictionary using the new
// serialization keys.
// TODO(crbug.com/691800): Remove legacy support.
NSDictionary<NSString*, id<NSCoding>>* GetDecodedLegacyValues(NSCoder* coder);
// The dictionary passed on initialization. After calling Decode(), this will
// contain the data that is decoded from the NSCoder.
base::scoped_nsobject<NSDictionary<NSString*, id<NSCoding>>> data_;
DISALLOW_COPY_AND_ASSIGN(SerializableUserDataImpl);
};
class SerializableUserDataManagerImpl : public SerializableUserDataManager {
public:
SerializableUserDataManagerImpl();
~SerializableUserDataManagerImpl();
// SerializableUserDataManager:
void AddSerializableData(id<NSCoding> data, NSString* key) override;
id<NSCoding> GetValueForSerializationKey(NSString* key) override;
std::unique_ptr<SerializableUserData> CreateSerializableUserData()
const override;
void AddSerializableUserData(SerializableUserData* data) override;
private:
// The dictionary that stores serializable user data.
base::scoped_nsobject<NSMutableDictionary<NSString*, id<NSCoding>>> data_;
DISALLOW_COPY_AND_ASSIGN(SerializableUserDataManagerImpl);
};
} // namespace web
#endif // IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_