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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/serializable_user_data_manager.h
diff --git a/ios/web/public/serializable_user_data_manager.h b/ios/web/public/serializable_user_data_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8a8596154a277d2fbdb56084834f0b92573a418
--- /dev/null
+++ b/ios/web/public/serializable_user_data_manager.h
@@ -0,0 +1,54 @@
+// 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_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
+#define IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
+
+#import <Foundation/Foundation.h>
+#include <memory>
+
+namespace web {
+
+class WebState;
+
+// Class used to serialize values added to SerializableUserDataManager.
+class SerializableUserData {
+ public:
+ // Factory method.
+ static std::unique_ptr<SerializableUserData> Create();
+
+ // Encodes the data with |coder|.
+ virtual void Encode(NSCoder* coder) = 0;
+
+ // Decodes the data from |coder|.
+ virtual void Decode(NSCoder* coder) = 0;
+};
+
+// Class that can be used to add serializable user data to a WebState.
+class SerializableUserDataManager {
+ public:
+ // Returns the SerializableUserDataManager instance associated with
+ // |web_state|, instantiating one if necessary.
+ static SerializableUserDataManager* FromWebState(web::WebState* web_state);
+
+ // Adds |data| to the user data, allowing it to be encoded under |key|.
+ // |data| is expected to be non-nil. If |key| has already been used, its
+ // associated value will be overwritten.
+ virtual void AddSerializableData(id<NSCoding> data, NSString* key) = 0;
+
+ // Returns the value that has been stored under |key|.
+ virtual id<NSCoding> GetValueForSerializationKey(NSString* key) = 0;
+
+ // Creates a SerializableUserData that can be used to encode the values added
+ // to the manager.
+ virtual std::unique_ptr<SerializableUserData> CreateSerializableUserData()
+ const = 0;
+
+ // Adds the values decoded from |data| to the manager.
+ virtual void AddSerializableUserData(SerializableUserData* data) = 0;
+};
+
+} // namespace web
+
+#endif // IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_
« 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