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

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

Issue 1360993002: Moved NavigationManagerImpl serialization out of CRWSessionController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/navigation/crw_serialized_navigation_manager.mm
diff --git a/ios/web/navigation/crw_serialized_navigation_manager.mm b/ios/web/navigation/crw_serialized_navigation_manager.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9c8320369ea1eb501a97cbd4e2455e50418a8f4f
--- /dev/null
+++ b/ios/web/navigation/crw_serialized_navigation_manager.mm
@@ -0,0 +1,106 @@
+// 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.
+
+#import "ios/web/navigation/crw_serialized_navigation_manager.h"
+
+#include "base/mac/objc_property_releaser.h"
+#import "ios/web/navigation/crw_session_certificate_policy_manager.h"
+
+namespace {
+// Serialization keys used in NSCoding functions.
+NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager";
+NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex";
+NSString* const kEntriesKey = @"entries";
+NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp";
+NSString* const kOpenerIdKey = @"openerId";
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 kOpenerIDKey
kkhorimoto 2015/09/24 18:12:59 Done.
+NSString* const kOpenedByDOMKey = @"openedByDOM";
+NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex";
+NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex";
+NSString* const kTabIdKey = @"tabId";
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 kTabIDKey
kkhorimoto 2015/09/24 18:12:59 Done.
+NSString* const kWindowNameKey = @"windowName";
+NSString* const kXCallbackParametersKey = @"xCallbackParameters";
+}
+
+@interface CRWSerializedNavigationManager () {
+ base::mac::ObjCPropertyReleaser
+ _propertyReleaser_CRWSerializedNavigationManager;
+}
+@end
+
+@implementation CRWSerializedNavigationManager
+
+@synthesize tabId = _tabId;
+@synthesize openerId = _openerId;
+@synthesize openedByDOM = _openedByDOM;
+@synthesize openerNavigationIndex = _openerNavigationIdes;
+@synthesize windowName = _windowName;
+@synthesize currentNavigationIndex = _currentNavigationIndex;
+@synthesize previousNavigationIndex = _previousNavigationIndex;
+@synthesize lastVisitedTimestamp = _lastVisitedTimestamp;
+@synthesize entries = _entries;
+@synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager;
+@synthesize xCallbackParameters = _xCallbackParameters;
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _propertyReleaser_CRWSerializedNavigationManager.Init(
+ self, [CRWSerializedNavigationManager class]);
+ }
+ return self;
+}
+
+- (instancetype)initWithCoder:(nonnull NSCoder*)aDecoder {
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 s/aDecoder/decoder
kkhorimoto 2015/09/24 18:12:59 Done.
+ self = [super init];
+ if (self) {
+ self.tabId = [aDecoder decodeObjectForKey:kTabIdKey];
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 Please don't access properties in init
kkhorimoto 2015/09/24 18:12:59 Done.
+ self.windowName = [aDecoder decodeObjectForKey:kWindowNameKey];
+ self.openerId = [aDecoder decodeObjectForKey:kOpenerIdKey];
+ self.openedByDOM = [aDecoder decodeBoolForKey:kOpenedByDOMKey];
+ self.openerNavigationIndex =
+ [aDecoder decodeIntForKey:kOpenerNavigationIndexKey];
+ self.currentNavigationIndex =
+ [aDecoder decodeIntForKey:kCurrentNavigationIndexKey];
+ self.previousNavigationIndex =
+ [aDecoder decodeIntForKey:kPreviousNavigationIndexKey];
+ self.lastVisitedTimestamp =
+ [aDecoder decodeDoubleForKey:kLastVisitedTimestampKey];
+ self.entries = [NSMutableArray
+ arrayWithArray:[aDecoder decodeObjectForKey:kEntriesKey]];
+ // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
+ if (!self.entries.count)
+ self.currentNavigationIndex = -1;
+ self.sessionCertificatePolicyManager =
+ [aDecoder decodeObjectForKey:kCertificatePolicyManagerKey];
+ if (!self.sessionCertificatePolicyManager) {
+ self.sessionCertificatePolicyManager =
+ [[CRWSessionCertificatePolicyManager alloc] init];
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 This is a memory leak
kkhorimoto 2015/09/24 18:12:59 Done.
+ }
+ self.xCallbackParameters =
+ [[aDecoder decodeObjectForKey:kXCallbackParametersKey] retain];
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 ditto
kkhorimoto 2015/09/24 18:12:59 Done.
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder*)aCoder {
Eugene But (OOO till 7-30) 2015/09/23 16:33:44 s/aCoder/coder
kkhorimoto 2015/09/24 18:12:59 Done.
+ [aCoder encodeObject:self.tabId forKey:kTabIdKey];
+ [aCoder encodeObject:self.openerId forKey:kOpenerIdKey];
+ [aCoder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey];
+ [aCoder encodeInt:self.openerNavigationIndex
+ forKey:kOpenerNavigationIndexKey];
+ [aCoder encodeObject:self.windowName forKey:kWindowNameKey];
+ [aCoder encodeInt:self.currentNavigationIndex
+ forKey:kCurrentNavigationIndexKey];
+ [aCoder encodeInt:self.previousNavigationIndex
+ forKey:kPreviousNavigationIndexKey];
+ [aCoder encodeDouble:self.lastVisitedTimestamp
+ forKey:kLastVisitedTimestampKey];
+ [aCoder encodeObject:self.entries forKey:kEntriesKey];
+ [aCoder encodeObject:self.sessionCertificatePolicyManager
+ forKey:kCertificatePolicyManagerKey];
+ [aCoder encodeObject:self.xCallbackParameters forKey:kXCallbackParametersKey];
+ // rendererInitiated is deliberately not preserved, as upstream.
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698