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

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

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « ios/net/cookies/cookie_store_ios_unittest.mm ('k') | ios/net/http_cache_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/mac/bind_objc_block.h" 15 #include "base/mac/bind_objc_block.h"
15 #include "base/mac/scoped_nsobject.h" 16 #include "base/mac/scoped_nsobject.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
17 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/strings/sys_string_conversions.h" 22 #include "base/strings/sys_string_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #import "ios/net/clients/crn_network_client_protocol.h" 24 #import "ios/net/clients/crn_network_client_protocol.h"
24 #import "ios/net/crn_http_protocol_handler_proxy_with_client_thread.h" 25 #import "ios/net/crn_http_protocol_handler_proxy_with_client_thread.h"
25 #import "ios/net/http_protocol_logging.h" 26 #import "ios/net/http_protocol_logging.h"
26 #include "ios/net/nsurlrequest_util.h" 27 #include "ios/net/nsurlrequest_util.h"
27 #import "ios/net/protocol_handler_util.h" 28 #import "ios/net/protocol_handler_util.h"
28 #include "ios/net/request_tracker.h" 29 #include "ios/net/request_tracker.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // NSURLProtocol client, and the following clients are ordered such as the 193 // NSURLProtocol client, and the following clients are ordered such as the
193 // ith client is responsible for managing the (i-1)th client. 194 // ith client is responsible for managing the (i-1)th client.
194 base::scoped_nsobject<NSMutableArray> clients_; 195 base::scoped_nsobject<NSMutableArray> clients_;
195 // Weak. This is the last client in |clients_|. 196 // Weak. This is the last client in |clients_|.
196 id<CRNNetworkClientProtocol> top_level_client_; 197 id<CRNNetworkClientProtocol> top_level_client_;
197 scoped_refptr<IOBuffer> buffer_; 198 scoped_refptr<IOBuffer> buffer_;
198 base::scoped_nsobject<NSMutableURLRequest> request_; 199 base::scoped_nsobject<NSMutableURLRequest> request_;
199 // Stream delegate to read the HTTPBodyStream. 200 // Stream delegate to read the HTTPBodyStream.
200 base::scoped_nsobject<CRWHTTPStreamDelegate> stream_delegate_; 201 base::scoped_nsobject<CRWHTTPStreamDelegate> stream_delegate_;
201 // Vector of readers used to accumulate a POST data stream. 202 // Vector of readers used to accumulate a POST data stream.
202 std::vector<scoped_ptr<UploadElementReader>> post_data_readers_; 203 std::vector<std::unique_ptr<UploadElementReader>> post_data_readers_;
203 204
204 // This cannot be a scoped pointer because it must be deleted on the IO 205 // This cannot be a scoped pointer because it must be deleted on the IO
205 // thread. 206 // thread.
206 URLRequest* net_request_; 207 URLRequest* net_request_;
207 208
208 base::WeakPtr<RequestTracker> tracker_; 209 base::WeakPtr<RequestTracker> tracker_;
209 210
210 DISALLOW_COPY_AND_ASSIGN(HttpProtocolHandlerCore); 211 DISALLOW_COPY_AND_ASSIGN(HttpProtocolHandlerCore);
211 }; 212 };
212 213
(...skipping 23 matching lines...) Expand all
236 << "Failed to read POST data: " 237 << "Failed to read POST data: "
237 << base::SysNSStringToUTF8([[stream streamError] description]); 238 << base::SysNSStringToUTF8([[stream streamError] description]);
238 StopListeningStream(stream); 239 StopListeningStream(stream);
239 StopRequestWithError(NSURLErrorUnknown, ERR_UNEXPECTED); 240 StopRequestWithError(NSURLErrorUnknown, ERR_UNEXPECTED);
240 break; 241 break;
241 case NSStreamEventEndEncountered: 242 case NSStreamEventEndEncountered:
242 StopListeningStream(stream); 243 StopListeningStream(stream);
243 if (!post_data_readers_.empty()) { 244 if (!post_data_readers_.empty()) {
244 // NOTE: This call will result in |post_data_readers_| being cleared, 245 // NOTE: This call will result in |post_data_readers_| being cleared,
245 // which is the desired behavior. 246 // which is the desired behavior.
246 net_request_->set_upload(make_scoped_ptr( 247 net_request_->set_upload(base::WrapUnique(
247 new ElementsUploadDataStream(std::move(post_data_readers_), 0))); 248 new ElementsUploadDataStream(std::move(post_data_readers_), 0)));
248 DCHECK(post_data_readers_.empty()); 249 DCHECK(post_data_readers_.empty());
249 } 250 }
250 net_request_->Start(); 251 net_request_->Start();
251 if (tracker_) 252 if (tracker_)
252 tracker_->StartRequest(net_request_); 253 tracker_->StartRequest(net_request_);
253 break; 254 break;
254 case NSStreamEventHasBytesAvailable: { 255 case NSStreamEventHasBytesAvailable: {
255 NSUInteger length; 256 NSUInteger length;
256 DCHECK([stream isKindOfClass:[NSInputStream class]]); 257 DCHECK([stream isKindOfClass:[NSInputStream class]]);
257 length = [(NSInputStream*)stream read:(unsigned char*)buffer_->data() 258 length = [(NSInputStream*)stream read:(unsigned char*)buffer_->data()
258 maxLength:kIOBufferSize]; 259 maxLength:kIOBufferSize];
259 if (length) { 260 if (length) {
260 std::vector<char> owned_data(buffer_->data(), buffer_->data() + length); 261 std::vector<char> owned_data(buffer_->data(), buffer_->data() + length);
261 post_data_readers_.push_back( 262 post_data_readers_.push_back(
262 make_scoped_ptr(new UploadOwnedBytesElementReader(&owned_data))); 263 base::WrapUnique(new UploadOwnedBytesElementReader(&owned_data)));
263 } 264 }
264 break; 265 break;
265 } 266 }
266 case NSStreamEventNone: 267 case NSStreamEventNone:
267 case NSStreamEventOpenCompleted: 268 case NSStreamEventOpenCompleted:
268 case NSStreamEventHasSpaceAvailable: 269 case NSStreamEventHasSpaceAvailable:
269 break; 270 break;
270 default: 271 default:
271 NOTREACHED() << "Unexpected stream event: " << event; 272 NOTREACHED() << "Unexpected stream event: " << event;
272 break; 273 break;
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 [input_stream open]; 715 [input_stream open];
715 // The request will be started when the stream is fully read. 716 // The request will be started when the stream is fully read.
716 return; 717 return;
717 } 718 }
718 719
719 NSData* body = [request_ HTTPBody]; 720 NSData* body = [request_ HTTPBody];
720 const NSUInteger body_length = [body length]; 721 const NSUInteger body_length = [body length];
721 if (body_length > 0) { 722 if (body_length > 0) {
722 const char* source_bytes = reinterpret_cast<const char*>([body bytes]); 723 const char* source_bytes = reinterpret_cast<const char*>([body bytes]);
723 std::vector<char> owned_data(source_bytes, source_bytes + body_length); 724 std::vector<char> owned_data(source_bytes, source_bytes + body_length);
724 scoped_ptr<UploadElementReader> reader( 725 std::unique_ptr<UploadElementReader> reader(
725 new UploadOwnedBytesElementReader(&owned_data)); 726 new UploadOwnedBytesElementReader(&owned_data));
726 net_request_->set_upload( 727 net_request_->set_upload(
727 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); 728 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
728 } 729 }
729 730
730 net_request_->Start(); 731 net_request_->Start();
731 if (tracker_) 732 if (tracker_)
732 tracker_->StartRequest(net_request_); 733 tracker_->StartRequest(net_request_);
733 } 734 }
734 735
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 [[DeferredCancellation alloc] initWithCore:[self getCore]]; 1096 [[DeferredCancellation alloc] initWithCore:[self getCore]];
1096 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; 1097 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ];
1097 [cancellation performSelector:@selector(cancel) 1098 [cancellation performSelector:@selector(cancel)
1098 onThread:[self getClientThread] 1099 onThread:[self getClientThread]
1099 withObject:nil 1100 withObject:nil
1100 waitUntilDone:NO 1101 waitUntilDone:NO
1101 modes:modes]; 1102 modes:modes];
1102 } 1103 }
1103 1104
1104 @end 1105 @end
OLDNEW
« no previous file with comments | « ios/net/cookies/cookie_store_ios_unittest.mm ('k') | ios/net/http_cache_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698