| OLD | NEW |
| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 << "Failed to read POST data: " | 237 << "Failed to read POST data: " |
| 238 << base::SysNSStringToUTF8([[stream streamError] description]); | 238 << base::SysNSStringToUTF8([[stream streamError] description]); |
| 239 StopListeningStream(stream); | 239 StopListeningStream(stream); |
| 240 StopRequestWithError(NSURLErrorUnknown, ERR_UNEXPECTED); | 240 StopRequestWithError(NSURLErrorUnknown, ERR_UNEXPECTED); |
| 241 break; | 241 break; |
| 242 case NSStreamEventEndEncountered: | 242 case NSStreamEventEndEncountered: |
| 243 StopListeningStream(stream); | 243 StopListeningStream(stream); |
| 244 if (!post_data_readers_.empty()) { | 244 if (!post_data_readers_.empty()) { |
| 245 // NOTE: This call will result in |post_data_readers_| being cleared, | 245 // NOTE: This call will result in |post_data_readers_| being cleared, |
| 246 // which is the desired behavior. | 246 // which is the desired behavior. |
| 247 net_request_->set_upload(base::WrapUnique( | 247 net_request_->set_upload(base::MakeUnique<ElementsUploadDataStream>( |
| 248 new ElementsUploadDataStream(std::move(post_data_readers_), 0))); | 248 std::move(post_data_readers_), 0)); |
| 249 DCHECK(post_data_readers_.empty()); | 249 DCHECK(post_data_readers_.empty()); |
| 250 } | 250 } |
| 251 net_request_->Start(); | 251 net_request_->Start(); |
| 252 if (tracker_) | 252 if (tracker_) |
| 253 tracker_->StartRequest(net_request_); | 253 tracker_->StartRequest(net_request_); |
| 254 break; | 254 break; |
| 255 case NSStreamEventHasBytesAvailable: { | 255 case NSStreamEventHasBytesAvailable: { |
| 256 NSUInteger length; | 256 NSUInteger length; |
| 257 DCHECK([stream isKindOfClass:[NSInputStream class]]); | 257 DCHECK([stream isKindOfClass:[NSInputStream class]]); |
| 258 length = [(NSInputStream*)stream read:(unsigned char*)buffer_->data() | 258 length = [(NSInputStream*)stream read:(unsigned char*)buffer_->data() |
| 259 maxLength:kIOBufferSize]; | 259 maxLength:kIOBufferSize]; |
| 260 if (length) { | 260 if (length) { |
| 261 std::vector<char> owned_data(buffer_->data(), buffer_->data() + length); | 261 std::vector<char> owned_data(buffer_->data(), buffer_->data() + length); |
| 262 post_data_readers_.push_back( | 262 post_data_readers_.push_back( |
| 263 base::WrapUnique(new UploadOwnedBytesElementReader(&owned_data))); | 263 base::MakeUnique<UploadOwnedBytesElementReader>(&owned_data)); |
| 264 } | 264 } |
| 265 break; | 265 break; |
| 266 } | 266 } |
| 267 case NSStreamEventNone: | 267 case NSStreamEventNone: |
| 268 case NSStreamEventOpenCompleted: | 268 case NSStreamEventOpenCompleted: |
| 269 case NSStreamEventHasSpaceAvailable: | 269 case NSStreamEventHasSpaceAvailable: |
| 270 break; | 270 break; |
| 271 default: | 271 default: |
| 272 NOTREACHED() << "Unexpected stream event: " << event; | 272 NOTREACHED() << "Unexpected stream event: " << event; |
| 273 break; | 273 break; |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 [[DeferredCancellation alloc] initWithCore:[self getCore]]; | 1096 [[DeferredCancellation alloc] initWithCore:[self getCore]]; |
| 1097 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; | 1097 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; |
| 1098 [cancellation performSelector:@selector(cancel) | 1098 [cancellation performSelector:@selector(cancel) |
| 1099 onThread:[self getClientThread] | 1099 onThread:[self getClientThread] |
| 1100 withObject:nil | 1100 withObject:nil |
| 1101 waitUntilDone:NO | 1101 waitUntilDone:NO |
| 1102 modes:modes]; | 1102 modes:modes]; |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 @end | 1105 @end |
| OLD | NEW |