| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // TODO(droger): It may be possible to avoid some of the copies (using | 533 // TODO(droger): It may be possible to avoid some of the copies (using |
| 534 // WrappedIOBuffer for example). | 534 // WrappedIOBuffer for example). |
| 535 NSUInteger data_length; | 535 NSUInteger data_length; |
| 536 uint64_t total_byte_read = 0; | 536 uint64_t total_byte_read = 0; |
| 537 while (bytes_read > 0) { | 537 while (bytes_read > 0) { |
| 538 total_byte_read += bytes_read; | 538 total_byte_read += bytes_read; |
| 539 data_length = [data length]; // Assumes that getting the length is fast. | 539 data_length = [data length]; // Assumes that getting the length is fast. |
| 540 [data increaseLengthBy:bytes_read]; | 540 [data increaseLengthBy:bytes_read]; |
| 541 memcpy(reinterpret_cast<char*>([data mutableBytes]) + data_length, | 541 memcpy(reinterpret_cast<char*>([data mutableBytes]) + data_length, |
| 542 buffer_->data(), bytes_read); | 542 buffer_->data(), bytes_read); |
| 543 request->Read(buffer_.get(), kIOBufferSize, &bytes_read); | 543 bytes_read = request->Read(buffer_.get(), kIOBufferSize); |
| 544 } | 544 } |
| 545 | 545 |
| 546 if (tracker_) | 546 if (tracker_) |
| 547 tracker_->CaptureReceivedBytes(request, total_byte_read); | 547 tracker_->CaptureReceivedBytes(request, total_byte_read); |
| 548 | 548 |
| 549 // Notify the client. | 549 // Notify the client. |
| 550 if (bytes_read == net::OK || bytes_read == net::ERR_IO_PENDING) { | 550 if (bytes_read == net::OK || bytes_read == net::ERR_IO_PENDING) { |
| 551 if ([data length] > 0) { | 551 if ([data length] > 0) { |
| 552 // If the data is not encoded in UTF8, the NSString is nil. | 552 // If the data is not encoded in UTF8, the NSString is nil. |
| 553 DVLOG(3) << "To client:" << std::endl | 553 DVLOG(3) << "To client:" << std::endl |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 [[DeferredCancellation alloc] initWithCore:[self getCore]]; | 1095 [[DeferredCancellation alloc] initWithCore:[self getCore]]; |
| 1096 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; | 1096 NSArray* modes = @[ [[NSRunLoop currentRunLoop] currentMode] ]; |
| 1097 [cancellation performSelector:@selector(cancel) | 1097 [cancellation performSelector:@selector(cancel) |
| 1098 onThread:[self getClientThread] | 1098 onThread:[self getClientThread] |
| 1099 withObject:nil | 1099 withObject:nil |
| 1100 waitUntilDone:NO | 1100 waitUntilDone:NO |
| 1101 modes:modes]; | 1101 modes:modes]; |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 @end | 1104 @end |
| OLD | NEW |