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

Side by Side Diff: ios/net/crn_http_protocol_handler.mm

Issue 2489533003: [ObjC ARC] Converts ios/net to ARC. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/net/crn_http_protocol_handler.h" 5 #import "ios/net/crn_http_protocol_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 #include "net/base/load_flags.h" 33 #include "net/base/load_flags.h"
34 #import "net/base/mac/url_conversions.h" 34 #import "net/base/mac/url_conversions.h"
35 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
36 #include "net/base/upload_bytes_element_reader.h" 36 #include "net/base/upload_bytes_element_reader.h"
37 #include "net/http/http_request_headers.h" 37 #include "net/http/http_request_headers.h"
38 #include "net/url_request/redirect_info.h" 38 #include "net/url_request/redirect_info.h"
39 #include "net/url_request/url_request.h" 39 #include "net/url_request/url_request.h"
40 #include "net/url_request/url_request_context.h" 40 #include "net/url_request/url_request_context.h"
41 #include "net/url_request/url_request_context_getter.h" 41 #include "net/url_request/url_request_context_getter.h"
42 42
43 #if !defined(__has_feature) || !__has_feature(objc_arc)
44 #error "This file requires ARC support."
45 #endif
46
43 namespace net { 47 namespace net {
44 class HttpProtocolHandlerCore; 48 class HttpProtocolHandlerCore;
45 } 49 }
46 50
47 namespace { 51 namespace {
48 52
49 // Size of the buffer used to read the net::URLRequest. 53 // Size of the buffer used to read the net::URLRequest.
50 const int kIOBufferSize = 4096; 54 const int kIOBufferSize = 4096;
51 55
52 // Global instance of the HTTPProtocolHandlerDelegate. 56 // Global instance of the HTTPProtocolHandlerDelegate.
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 548 }
545 549
546 if (tracker_) 550 if (tracker_)
547 tracker_->CaptureReceivedBytes(request, total_byte_read); 551 tracker_->CaptureReceivedBytes(request, total_byte_read);
548 552
549 // Notify the client. 553 // Notify the client.
550 if (bytes_read == net::OK || bytes_read == net::ERR_IO_PENDING) { 554 if (bytes_read == net::OK || bytes_read == net::ERR_IO_PENDING) {
551 if ([data length] > 0) { 555 if ([data length] > 0) {
552 // If the data is not encoded in UTF8, the NSString is nil. 556 // If the data is not encoded in UTF8, the NSString is nil.
553 DVLOG(3) << "To client:" << std::endl 557 DVLOG(3) << "To client:" << std::endl
554 << base::SysNSStringToUTF8([[[NSString alloc] 558 << base::SysNSStringToUTF8([[NSString alloc]
555 initWithData:data 559 initWithData:data
556 encoding:NSUTF8StringEncoding] autorelease]); 560 encoding:NSUTF8StringEncoding]);
557 [top_level_client_ didLoadData:data]; 561 [top_level_client_ didLoadData:data];
558 } 562 }
559 if (bytes_read == 0) { 563 if (bytes_read == 0) {
560 DCHECK_EQ(net_request_, request); 564 DCHECK_EQ(net_request_, request);
561 // There is nothing more to read. 565 // There is nothing more to read.
562 StopNetRequest(); 566 StopNetRequest();
563 [top_level_client_ didFinishLoading]; 567 [top_level_client_ didFinishLoading];
564 } 568 }
565 } else { 569 } else {
566 // Request failed (not canceled). 570 // Request failed (not canceled).
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // (CRNHTTPProtocolHandler) because it is convenient. 1061 // (CRNHTTPProtocolHandler) because it is convenient.
1058 @implementation CRNPauseableHTTPProtocolHandler { 1062 @implementation CRNPauseableHTTPProtocolHandler {
1059 BOOL _started; 1063 BOOL _started;
1060 dispatch_queue_t _queue; 1064 dispatch_queue_t _queue;
1061 } 1065 }
1062 1066
1063 #pragma mark NSURLProtocol methods 1067 #pragma mark NSURLProtocol methods
1064 1068
1065 - (void)dealloc { 1069 - (void)dealloc {
1066 [self scheduleCancelRequest]; 1070 [self scheduleCancelRequest];
1067 [super dealloc];
1068 } 1071 }
1069 1072
1070 #pragma mark NSURLProtocol overrides. 1073 #pragma mark NSURLProtocol overrides.
1071 1074
1072 - (void)startLoading { 1075 - (void)startLoading {
1073 if (_started) { 1076 if (_started) {
1074 [[self getProtocolHandlerProxy] resume]; 1077 [[self getProtocolHandlerProxy] resume];
1075 return; 1078 return;
1076 } 1079 }
1077 1080
(...skipping 17 matching lines...) Expand all
1095 [[DeferredCancellation alloc] initWithCore:[self getCore]]; 1098 [[DeferredCancellation alloc] initWithCore:[self getCore]];
1096 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; 1099 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ];
1097 [cancellation performSelector:@selector(cancel) 1100 [cancellation performSelector:@selector(cancel)
1098 onThread:[self getClientThread] 1101 onThread:[self getClientThread]
1099 withObject:nil 1102 withObject:nil
1100 waitUntilDone:NO 1103 waitUntilDone:NO
1101 modes:modes]; 1104 modes:modes];
1102 } 1105 }
1103 1106
1104 @end 1107 @end
OLDNEW
« no previous file with comments | « ios/net/cookies/system_cookie_util.mm ('k') | ios/net/crn_http_protocol_handler_proxy_with_client_thread.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698