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

Unified Diff: ios/web/public/serialized_user_data_manager.h

Issue 1361173005: Created SerializedUserDataManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serialized_navigation_manager
Patch Set: Eugene's comments Created 5 years, 3 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
Index: ios/web/public/serialized_user_data_manager.h
diff --git a/ios/web/public/serialized_user_data_manager.h b/ios/web/public/serialized_user_data_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f21346c3b6a2a8ed76d3a605f42c2670279fe56
--- /dev/null
+++ b/ios/web/public/serialized_user_data_manager.h
@@ -0,0 +1,57 @@
+// Copyright 2015 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_SERIALIZED_USER_DATA_MANAGER_H_
+#define IOS_WEB_PUBLIC_SERIALIZED_USER_DATA_MANAGER_H_
+
+#include "base/supports_user_data.h"
+
+#if defined(__OBJC__)
+@protocol NSCoding;
+@class NSDictionary;
+@class NSString;
+typedef id<NSCoding> SerializedUserDataType;
+#else
+class NSDictionary;
+class NSString;
+typedef void* SerializedUserDataType;
+#endif // defined(__OBJC__)
+
+namespace web {
+
+class WebState;
+
+// Class that manages arbitrary persistent data that can be added to a
+// NavigationManager.
+class SerializedUserDataManager {
+ public:
+ virtual ~SerializedUserDataManager() {}
+
+ // Returns a SerializedUserDataManager for |web_state|, lazily instantiating
+ // one if necessary. |web_state| must be non-null.
+ static SerializedUserDataManager* FromWebState(WebState* web_state);
+
+ // Associates |data| with the NavigationManager under |serialization_key|.
+ // |data| is retained by the manager, and |serialization_key| is copied. If
+ // |data| is nil, the value previously stored under |serialization_key| is
+ // removed. |serialization_key| must be non-empty.
+ virtual void SetValueForSerializationKey(SerializedUserDataType data,
+ NSString* serialization_key) = 0;
+
+ // Returns the value associated with |serialization_key|. |serialization_key|
+ // must be non-empty.
+ virtual SerializedUserDataType GetValueForSerializationKey(
+ NSString* serialization_key) const = 0;
+
+ // Returns an NSDictionary containing copies of the serializable key value
+ // pairs.
+ virtual NSDictionary* GetSerializationDictionary() const = 0;
+
+ // Adds values and serialization keys from |dictionary| to the manager.
+ // |dictionary| must be non-nil.
+ virtual void AddValuesFromDictionary(NSDictionary* dictionary) = 0;
+};
+}
Eugene But (OOO till 7-30) 2015/09/24 21:39:25 NIT: // namespace web
+
+#endif // IOS_WEB_PUBLIC_SERIALIZED_USER_DATA_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698