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