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

Unified Diff: ios/web/navigation/nscoder_util.mm

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
Patch Set: Created 5 years, 9 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/navigation/nscoder_util.mm
diff --git a/ios/web/navigation/nscoder_util.mm b/ios/web/navigation/nscoder_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..551dccd27a09697dffb0fe0f3fd956c60e206b06
--- /dev/null
+++ b/ios/web/navigation/nscoder_util.mm
@@ -0,0 +1,25 @@
+// Copyright (c) 2012 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.
+
+#include <string>
+
+#include "ios/web/navigation/nscoder_util.h"
+
+namespace web {
+namespace nscoder_util {
+
+void EncodeString(NSCoder* coder, NSString* key, const std::string& string) {
+ [coder encodeBytes:reinterpret_cast<const uint8_t*>(string.data())
+ length:string.size()
+ forKey:key];
+}
+
+std::string DecodeString(NSCoder* decoder, NSString* key) {
+ NSUInteger length;
Eugene But (OOO till 7-30) 2015/03/09 16:17:43 NIT: initialize
+ const uint8_t* bytes = [decoder decodeBytesForKey:key returnedLength:&length];
+ return std::string(reinterpret_cast<const char*>(bytes), length);
+}
+
+} // namespace nscoder_util
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698