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

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

Issue 2202623002: Converts parts of ios/web to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extra release Created 4 years, 4 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_session_controller.mm
diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm
index 85938fc01aff0d57368e09a92d71d18613ace9aa..c5078c9d9e8d4d4df37908eaf4af2722133887ab 100644
--- a/ios/web/navigation/crw_session_controller.mm
+++ b/ios/web/navigation/crw_session_controller.mm
@@ -12,7 +12,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
-#include "base/mac/objc_property_releaser.h"
+#import "base/mac/foundation_util.h"
#import "base/mac/scoped_nsobject.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
@@ -30,6 +30,10 @@
#include "ios/web/public/referrer.h"
#include "ios/web/public/ssl_status.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::UserMetricsAction;
namespace {
@@ -102,8 +106,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
// XCallback parameters used to create (or clobber) the tab. Can be nil.
XCallbackParameters* _xCallbackParameters;
-
- base::mac::ObjCPropertyReleaser _propertyReleaser_CRWSessionController;
}
// Redefine as readwrite.
@@ -111,9 +113,9 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
// TODO(rohitrao): These properties must be redefined readwrite to work around a
// clang bug. crbug.com/228650
-@property(nonatomic, readwrite, retain) NSString* tabId;
-@property(nonatomic, readwrite, retain) NSArray* entries;
-@property(nonatomic, readwrite, retain)
+@property(nonatomic, readwrite, copy) NSString* tabId;
+@property(nonatomic, readwrite, strong) NSArray* entries;
+@property(nonatomic, readwrite, strong)
CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager;
- (NSString*)uniqueID;
@@ -153,15 +155,13 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
browserState:(web::BrowserState*)browserState {
self = [super init];
if (self) {
- _propertyReleaser_CRWSessionController.Init(self,
- [CRWSessionController class]);
self.windowName = windowName;
- _tabId = [[self uniqueID] retain];
+ _tabId = [[self uniqueID] copy];
_openerId = [openerId copy];
_openedByDOM = openedByDOM;
_openerNavigationIndex = openerIndex;
_browserState = browserState;
- _entries = [[NSMutableArray array] retain];
+ _entries = [NSMutableArray array];
_lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970];
_currentNavigationIndex = -1;
_previousNavigationIndex = -1;
@@ -176,9 +176,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
browserState:(web::BrowserState*)browserState {
self = [super init];
if (self) {
- _propertyReleaser_CRWSessionController.Init(self,
- [CRWSessionController class]);
- _tabId = [[self uniqueID] retain];
+ _tabId = [[self uniqueID] copy];
_openerId = nil;
_browserState = browserState;
@@ -211,14 +209,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
- (id)initWithCoder:(NSCoder*)aDecoder {
self = [super init];
if (self) {
- _propertyReleaser_CRWSessionController.Init(self,
- [CRWSessionController class]);
NSString* uuid = [aDecoder decodeObjectForKey:kTabIdKey];
if (!uuid)
uuid = [self uniqueID];
self.windowName = [aDecoder decodeObjectForKey:kWindowNameKey];
- _tabId = [uuid retain];
+ _tabId = [uuid copy];
_openerId = [[aDecoder decodeObjectForKey:kOpenerIdKey] copy];
_openedByDOM = [aDecoder decodeBoolForKey:kOpenedByDOMKey];
_openerNavigationIndex =
@@ -232,19 +228,19 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
NSMutableArray* temp =
[NSMutableArray arrayWithArray:
[aDecoder decodeObjectForKey:kEntriesKey]];
- _entries = [temp retain];
+ _entries = temp;
// Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
if (![_entries count])
_currentNavigationIndex = -1;
_sessionCertificatePolicyManager =
- [[aDecoder decodeObjectForKey:kCertificatePolicyManagerKey] retain];
+ [aDecoder decodeObjectForKey:kCertificatePolicyManagerKey];
if (!_sessionCertificatePolicyManager) {
_sessionCertificatePolicyManager =
[[CRWSessionCertificatePolicyManager alloc] init];
}
_xCallbackParameters =
- [[aDecoder decodeObjectForKey:kXCallbackParametersKey] retain];
+ [aDecoder decodeObjectForKey:kXCallbackParametersKey];
}
return self;
}
@@ -268,8 +264,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
- (id)copyWithZone:(NSZone*)zone {
CRWSessionController* copy = [[[self class] alloc] init];
- copy->_propertyReleaser_CRWSessionController.Init(
- copy, [CRWSessionController class]);
copy->_tabId = [_tabId copy];
copy->_openerId = [_openerId copy];
copy->_openedByDOM = _openedByDOM;
@@ -282,7 +276,8 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
[[NSMutableArray alloc] initWithArray:_entries copyItems:YES];
copy->_sessionCertificatePolicyManager =
[_sessionCertificatePolicyManager copy];
- copy->_xCallbackParameters = [_xCallbackParameters copy];
+ copy->_xCallbackParameters = [base::mac::ObjCCastStrict<NSObject<NSCopying>>(
+ _xCallbackParameters) copy];
return copy;
}
@@ -401,11 +396,11 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
(self.currentEntry.navigationItem &&
self.currentEntry.navigationItem->IsOverridingUserAgent());
_useDesktopUserAgentForNextPendingEntry = NO;
- _pendingEntry.reset([[self sessionEntryWithURL:url
- referrer:ref
- transition:trans
- useDesktopUserAgent:useDesktopUserAgent
- rendererInitiated:rendererInitiated] retain]);
+ _pendingEntry.reset([self sessionEntryWithURL:url
+ referrer:ref
+ transition:trans
+ useDesktopUserAgent:useDesktopUserAgent
+ rendererInitiated:rendererInitiated]);
kkhorimoto 2016/08/19 23:15:43 How do scoped_nsobjects work within an ARC context
stkhapugin 2016/08/22 11:37:00 As I said in design docs, PSAs and the lightning t
if (_navigationManager && _navigationManager->GetFacadeDelegate()) {
_navigationManager->GetFacadeDelegate()->OnNavigationItemPending();
@@ -454,7 +449,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
// Store removed items in temporary NSArray so they can be deallocated after
// their facades.
base::scoped_nsobject<NSArray> removedItems(
- [[_entries subarrayWithRange:remove] retain]);
+ [_entries subarrayWithRange:remove]);
[_entries removeObjectsInRange:remove];
if (_previousNavigationIndex >= forwardEntryStartIndex)
_previousNavigationIndex = -1;
@@ -487,12 +482,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
}
- (void)addTransientEntryWithURL:(const GURL&)URL {
- _transientEntry.reset(
- [[self sessionEntryWithURL:URL
- referrer:web::Referrer()
- transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT
- useDesktopUserAgent:NO
- rendererInitiated:NO] retain]);
+ _transientEntry.reset([self
+ sessionEntryWithURL:URL
+ referrer:web::Referrer()
+ transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT
+ useDesktopUserAgent:NO
+ rendererInitiated:NO]);
web::NavigationItem* navigationItem = [_transientEntry navigationItem];
DCHECK(navigationItem);
@@ -510,12 +505,12 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
web::Referrer referrer(item->GetURL(), web::ReferrerPolicyDefault);
bool overrideUserAgent =
self.currentEntry.navigationItem->IsOverridingUserAgent();
- base::scoped_nsobject<CRWSessionEntry> pushedEntry(
- [[self sessionEntryWithURL:URL
- referrer:referrer
- transition:transition
- useDesktopUserAgent:overrideUserAgent
- rendererInitiated:NO] retain]);
+ base::scoped_nsobject<CRWSessionEntry> pushedEntry([self
+ sessionEntryWithURL:URL
+ referrer:referrer
+ transition:transition
+ useDesktopUserAgent:overrideUserAgent
+ rendererInitiated:NO]);
web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl];
pushedItem->SetSerializedStateObject(stateObject);
pushedItem->SetIsCreatedFromPushState(true);
@@ -556,7 +551,6 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
// entry; since navigations clear the transient entry, these flows might
// crash. (This should be removable once more session management is handled
// within this class and/or NavigationManager).
- [[_transientEntry retain] autorelease];
_transientEntry.reset();
}
@@ -572,8 +566,8 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
self.currentNavigationIndex = -1;
_previousNavigationIndex = -1;
}
- self.xCallbackParameters =
- [[otherSession.xCallbackParameters copy] autorelease];
+ self.xCallbackParameters = [base::mac::ObjCCastStrict<NSObject<NSCopying>>(
+ otherSession.xCallbackParameters) copy];
self.windowName = otherSession.windowName;
NSInteger numInitialEntries = [_entries count];
@@ -849,9 +843,9 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
- (NSString*)uniqueID {
CFUUIDRef uuidRef = CFUUIDCreate(NULL);
CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
- CFRelease(uuidRef);
- NSString* uuid = [NSString stringWithString:(NSString*)uuidStringRef];
- CFRelease(uuidStringRef);
+ NSString* uuid =
+ [NSString stringWithString:base::mac::ObjCCastStrict<NSString>(
+ CFBridgingRelease(uuidStringRef))];
return uuid;
}
@@ -880,8 +874,7 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
item->SetTransitionType(transition);
item->SetIsOverridingUserAgent(useDesktopUserAgent);
item->set_is_renderer_initiated(rendererInitiated);
- return [[[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]
- autorelease];
+ return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)];
}
@end

Powered by Google App Engine
This is Rietveld 408576698