Commit 752abca0 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

Converts ios/web/net to ARC.

Converts files located in ios/web/net.

Removes property_releaser usage. Includes results of ARCMigrate run.
Replaces WeakNSObjects with __weak variables. Inserts compile guards.

Additionaly, renames ivars from trailing underscore to leading.

BUG=624365
TEST=None

Review-Url: https://codereview.chromium.org/2247303009
Cr-Commit-Position: refs/heads/master@{#414417}
parent 24bf4ca3
......@@ -62,6 +62,36 @@ source_set("web_arc") {
"navigation/nscoder_util.mm",
"navigation/time_smoother.cc",
"navigation/time_smoother.h",
"net/cert_host_pair.cc",
"net/cert_host_pair.h",
"net/cert_policy.cc",
"net/cert_store_impl.cc",
"net/cert_store_impl.h",
"net/certificate_policy_cache.cc",
"net/clients/crw_js_injection_network_client.h",
"net/clients/crw_js_injection_network_client.mm",
"net/clients/crw_js_injection_network_client_factory.h",
"net/clients/crw_js_injection_network_client_factory.mm",
"net/clients/crw_redirect_network_client.h",
"net/clients/crw_redirect_network_client.mm",
"net/clients/crw_redirect_network_client_factory.h",
"net/clients/crw_redirect_network_client_factory.mm",
"net/cookie_notification_bridge.h",
"net/cookie_notification_bridge.mm",
"net/crw_cert_verification_controller.h",
"net/crw_cert_verification_controller.mm",
"net/crw_request_tracker_delegate.h",
"net/crw_ssl_status_updater.h",
"net/crw_ssl_status_updater.mm",
"net/request_group_util.h",
"net/request_group_util.mm",
"net/request_tracker_data_memoizing_store.h",
"net/request_tracker_factory_impl.h",
"net/request_tracker_factory_impl.mm",
"net/request_tracker_impl.h",
"net/request_tracker_impl.mm",
"net/web_http_protocol_handler_delegate.h",
"net/web_http_protocol_handler_delegate.mm",
"string_util.cc",
"url_scheme_util.mm",
"url_util.cc",
......@@ -102,36 +132,6 @@ source_set("web") {
]
sources = [
"net/cert_host_pair.cc",
"net/cert_host_pair.h",
"net/cert_policy.cc",
"net/cert_store_impl.cc",
"net/cert_store_impl.h",
"net/certificate_policy_cache.cc",
"net/clients/crw_js_injection_network_client.h",
"net/clients/crw_js_injection_network_client.mm",
"net/clients/crw_js_injection_network_client_factory.h",
"net/clients/crw_js_injection_network_client_factory.mm",
"net/clients/crw_redirect_network_client.h",
"net/clients/crw_redirect_network_client.mm",
"net/clients/crw_redirect_network_client_factory.h",
"net/clients/crw_redirect_network_client_factory.mm",
"net/cookie_notification_bridge.h",
"net/cookie_notification_bridge.mm",
"net/crw_cert_verification_controller.h",
"net/crw_cert_verification_controller.mm",
"net/crw_request_tracker_delegate.h",
"net/crw_ssl_status_updater.h",
"net/crw_ssl_status_updater.mm",
"net/request_group_util.h",
"net/request_group_util.mm",
"net/request_tracker_data_memoizing_store.h",
"net/request_tracker_factory_impl.h",
"net/request_tracker_factory_impl.mm",
"net/request_tracker_impl.h",
"net/request_tracker_impl.mm",
"net/web_http_protocol_handler_delegate.h",
"net/web_http_protocol_handler_delegate.mm",
"payments/payment_request.cc",
"public/active_state_manager.h",
"public/block_types.h",
......
......@@ -8,12 +8,15 @@
#include <stdint.h>
#include "base/logging.h"
#include "base/mac/objc_property_releaser.h"
#include "base/mac/scoped_nsobject.h"
#include "base/metrics/histogram.h"
#import "ios/net/crn_http_url_response.h"
#import "ios/third_party/blink/src/html_tokenizer.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// CRWJSInjectionNetworkClient injects an external script tag reference for
// crweb.js into HTML and XHTML documents. To do this correctly, three data
// points are needed: where to inject the script tag, what encoding the content
......@@ -146,7 +149,7 @@ CRNHTTPURLResponse* ResponseWithUpdatedContentSize(
HTTPVersion:[response cr_HTTPVersion]
headerFields:all_headers_mutable];
return [update_response autorelease];
return update_response;
}
} // namespace
......@@ -298,7 +301,7 @@ CRNHTTPURLResponse* ResponseWithUpdatedContentSize(
[super didReceiveResponse:response];
} else {
// Client calls [super didReceiveResponse:] in sendPendingResponse.
_pendingResponse.reset([static_cast<CRNHTTPURLResponse*>(response) retain]);
_pendingResponse.reset(static_cast<CRNHTTPURLResponse*>(response));
}
}
......@@ -350,7 +353,7 @@ CRNHTTPURLResponse* ResponseWithUpdatedContentSize(
NSString* jsContentString = [NSString
stringWithFormat:kJSContentTemplate, [[NSUUID UUID] UUIDString]];
_jsInjectionContent.reset(
[[jsContentString dataUsingEncoding:_contentEncoding] retain]);
[jsContentString dataUsingEncoding:_contentEncoding]);
return _jsInjectionContent;
}
......@@ -393,7 +396,7 @@ CRNHTTPURLResponse* ResponseWithUpdatedContentSize(
NSUInteger additionalLength = [[self jsInjectionContent] length];
CRNHTTPURLResponse* responseToSend =
ResponseWithUpdatedContentSize(_pendingResponse, additionalLength);
_pendingResponse.reset([responseToSend retain]);
_pendingResponse.reset(responseToSend);
}
[super didReceiveResponse:_pendingResponse];
......
......@@ -8,6 +8,10 @@
#include "ios/web/net/clients/crw_js_injection_network_client.h"
#include "net/url_request/url_request.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation CRWJSInjectionNetworkClientFactory
- (CRWJSInjectionNetworkClient*)
......@@ -29,7 +33,7 @@
static_cast<int>(web::InjectionResult::INJECTION_RESULT_COUNT));
return nil;
}
return [[[CRWJSInjectionNetworkClient alloc] init] autorelease];
return [[CRWJSInjectionNetworkClient alloc] init];
}
return nil;
}
......
......@@ -7,7 +7,6 @@
#import <Foundation/Foundation.h>
#include "base/ios/weak_nsobject.h"
#import "ios/net/clients/crn_forwarding_network_client.h"
@protocol CRWRedirectClientDelegate;
......@@ -17,8 +16,7 @@
@interface CRWRedirectNetworkClient : CRNForwardingNetworkClient
// Designated initializer.
- (instancetype)initWithDelegate:
(base::WeakNSProtocol<id<CRWRedirectClientDelegate>>)delegate;
- (instancetype)initWithDelegate:(id<CRWRedirectClientDelegate>)delegate;
@end
......
......@@ -8,24 +8,23 @@
#include "base/mac/bind_objc_block.h"
#include "ios/web/public/web_thread.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface CRWRedirectNetworkClient () {
// The delegate.
base::WeakNSProtocol<id<CRWRedirectClientDelegate>> delegate_;
__weak id<CRWRedirectClientDelegate> _delegate;
}
@end
@implementation CRWRedirectNetworkClient
- (instancetype)initWithDelegate:
(base::WeakNSProtocol<id<CRWRedirectClientDelegate>>)delegate {
- (instancetype)initWithDelegate:(id<CRWRedirectClientDelegate>)delegate {
self = [super init];
if (self) {
// CRWRedirectNetworkClients are created on the IO thread, but due to the
// threading restrictions of WeakNSObjects, |delegate_| may only be
// dereferenced on the UI thread.
DCHECK_CURRENTLY_ON(web::WebThread::IO);
delegate_ = delegate;
_delegate = delegate;
}
return self;
}
......@@ -40,10 +39,10 @@
redirectResponse:(NSURLResponse*)redirectResponse {
DCHECK_CURRENTLY_ON(web::WebThread::IO);
web::WebThread::PostTask(web::WebThread::UI, FROM_HERE, base::BindBlock(^{
// |delegate_| can only be dereferenced from the UI thread.
[delegate_ wasRedirectedToRequest:request
redirectResponse:redirectResponse];
}));
[_delegate
wasRedirectedToRequest:request
redirectResponse:redirectResponse];
}));
[super wasRedirectedToRequest:request
nativeRequest:nativeRequest
redirectResponse:redirectResponse];
......
......@@ -5,16 +5,18 @@
#include "ios/web/net/clients/crw_redirect_network_client_factory.h"
#include "base/location.h"
#import "base/ios/weak_nsobject.h"
#include "base/mac/bind_objc_block.h"
#include "ios/web/public/web_thread.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface CRWRedirectNetworkClientFactory () {
// Delegate passed to each vended CRWRedirectClient.
base::WeakNSProtocol<id<CRWRedirectClientDelegate>> client_delegate_;
__weak id<CRWRedirectClientDelegate> _client_delegate;
}
@end
......@@ -26,7 +28,7 @@
if (self) {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
DCHECK(delegate);
client_delegate_.reset(delegate);
_client_delegate = delegate;
}
return self;
}
......@@ -47,8 +49,7 @@
url:(const GURL&)url
response:(NSURLResponse*)response {
DCHECK_CURRENTLY_ON(web::WebThread::IO);
return [[[CRWRedirectNetworkClient alloc]
initWithDelegate:client_delegate_] autorelease];
return [[CRWRedirectNetworkClient alloc] initWithDelegate:_client_delegate];
}
@end
......@@ -11,6 +11,10 @@
#include "ios/net/cookies/cookie_store_ios.h"
#include "ios/web/public/web_thread.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace web {
CookieNotificationBridge::CookieNotificationBridge() {
......@@ -21,7 +25,7 @@ CookieNotificationBridge::CookieNotificationBridge() {
usingBlock:^(NSNotification* notification) {
OnNotificationReceived(notification);
}];
observer_.reset([observer retain]);
observer_.reset(observer);
}
CookieNotificationBridge::~CookieNotificationBridge() {
......
......@@ -18,6 +18,10 @@
#import "ios/web/web_state/wk_web_view_security_util.h"
#include "net/cert/cert_verify_proc_ios.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface CRWCertVerificationController () {
// Used to remember user exceptions to invalid certs.
scoped_refptr<web::CertificatePolicyCache> _certPolicyCache;
......
......@@ -15,6 +15,10 @@
#include "net/cert/x509_certificate.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using base::ScopedCFTypeRef;
using net::CertStatus;
using web::SecurityStyle;
......
......@@ -13,6 +13,10 @@
#import "net/base/mac/url_conversions.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Minimum length for a request group ID. A shorter string is considered as an
// invalid ID.
......
......@@ -10,6 +10,10 @@
#include "ios/web/net/request_group_util.h"
#include "ios/web/net/request_tracker_impl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace web {
RequestTrackerFactoryImpl::RequestTrackerFactoryImpl(
......
......@@ -33,6 +33,10 @@
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
struct EqualNSStrings {
......@@ -254,7 +258,7 @@ struct TrackerCounts {
}
- (void)errorCallback:(BOOL)flag {
base::scoped_nsobject<CRWSSLCarrier> scoped([self retain]);
base::scoped_nsobject<CRWSSLCarrier> scoped(self);
web::WebThread::PostTask(web::WebThread::IO, FROM_HERE,
base::Bind(&web::RequestTrackerImpl::ErrorCallback,
tracker_, scoped, flag));
......@@ -368,7 +372,7 @@ RequestTrackerImpl::CreateTrackerForRequestGroupID(
void RequestTrackerImpl::StartPageLoad(const GURL& url, id user_info) {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
base::scoped_nsobject<id> scoped_user_info([user_info retain]);
base::scoped_nsobject<id> scoped_user_info(user_info);
web::WebThread::PostTask(
web::WebThread::IO, FROM_HERE,
base::Bind(&RequestTrackerImpl::TrimToURL, this, url, scoped_user_info));
......@@ -1227,7 +1231,7 @@ void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
has_mixed_content_ = new_url_has_mixed_content;
page_url_ = url;
user_info_.reset([user_info retain]);
user_info_.reset(user_info);
estimate_start_index_ = 0;
is_loading_ = true;
previous_estimate_ = 0.0f;
......
......@@ -11,6 +11,10 @@
#include "net/url_request/url_request_context_getter.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
bool IsAppSpecificScheme(NSURL* url) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment