| 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 <utility> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
| 14 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 scoped_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(reader.Pass(), 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 |
| 735 void HttpProtocolHandlerCore::Cancel() { | 736 void HttpProtocolHandlerCore::Cancel() { |
| 736 DCHECK(thread_checker_.CalledOnValidThread()); | 737 DCHECK(thread_checker_.CalledOnValidThread()); |
| 737 if (net_request_ == nullptr) | 738 if (net_request_ == nullptr) |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |