| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/browser/streams/stream_url_request_job.h" | 5 #include "content/browser/streams/stream_url_request_job.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 *info = *response_info_; | 138 *info = *response_info_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 int StreamURLRequestJob::GetResponseCode() const { | 141 int StreamURLRequestJob::GetResponseCode() const { |
| 142 if (!response_info_) | 142 if (!response_info_) |
| 143 return -1; | 143 return -1; |
| 144 | 144 |
| 145 return response_info_->headers->response_code(); | 145 return response_info_->headers->response_code(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 int64_t StreamURLRequestJob::GetTotalReceivedBytes() const { |
| 149 int64_t total_received_bytes = 0; |
| 150 if (response_info_) |
| 151 total_received_bytes = response_info_->headers->raw_headers().size(); |
| 152 if (stream_.get()) |
| 153 total_received_bytes += total_bytes_read_; |
| 154 return total_received_bytes; |
| 155 } |
| 156 |
| 148 void StreamURLRequestJob::DidStart() { | 157 void StreamURLRequestJob::DidStart() { |
| 149 if (range_parse_result() == net::OK && ranges().size() > 0) { | 158 if (range_parse_result() == net::OK && ranges().size() > 0) { |
| 150 // Only one range is supported, and it must start at the first byte. | 159 // Only one range is supported, and it must start at the first byte. |
| 151 if (ranges().size() > 1 || ranges()[0].first_byte_position() != 0) { | 160 if (ranges().size() > 1 || ranges()[0].first_byte_position() != 0) { |
| 152 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); | 161 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); |
| 153 return; | 162 return; |
| 154 } | 163 } |
| 155 | 164 |
| 156 max_range_ = ranges()[0].last_byte_position() + 1; | 165 max_range_ = ranges()[0].last_byte_position() + 1; |
| 157 } | 166 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 226 } |
| 218 | 227 |
| 219 void StreamURLRequestJob::ClearStream() { | 228 void StreamURLRequestJob::ClearStream() { |
| 220 if (stream_.get()) { | 229 if (stream_.get()) { |
| 221 stream_->RemoveReadObserver(this); | 230 stream_->RemoveReadObserver(this); |
| 222 stream_ = NULL; | 231 stream_ = NULL; |
| 223 } | 232 } |
| 224 } | 233 } |
| 225 | 234 |
| 226 } // namespace content | 235 } // namespace content |
| OLD | NEW |