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" |
| 8 #include "base/single_thread_task_runner.h" |
7 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/thread_task_runner_handle.h" |
8 #include "content/browser/streams/stream.h" | 11 #include "content/browser/streams/stream.h" |
9 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
11 #include "net/http/http_byte_range.h" | 14 #include "net/http/http_byte_range.h" |
12 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
13 #include "net/http/http_response_info.h" | 16 #include "net/http/http_response_info.h" |
14 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
15 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
16 | 19 |
17 namespace content { | 20 namespace content { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 pending_buffer_ = NULL; | 76 pending_buffer_ = NULL; |
74 pending_buffer_size_ = 0; | 77 pending_buffer_size_ = 0; |
75 | 78 |
76 total_bytes_read_ += bytes_read; | 79 total_bytes_read_ += bytes_read; |
77 NotifyReadComplete(bytes_read); | 80 NotifyReadComplete(bytes_read); |
78 } | 81 } |
79 | 82 |
80 // net::URLRequestJob methods. | 83 // net::URLRequestJob methods. |
81 void StreamURLRequestJob::Start() { | 84 void StreamURLRequestJob::Start() { |
82 // Continue asynchronously. | 85 // Continue asynchronously. |
83 base::MessageLoop::current()->PostTask( | 86 base::ThreadTaskRunnerHandle::Get()->PostTask( |
84 FROM_HERE, | 87 FROM_HERE, |
85 base::Bind(&StreamURLRequestJob::DidStart, weak_factory_.GetWeakPtr())); | 88 base::Bind(&StreamURLRequestJob::DidStart, weak_factory_.GetWeakPtr())); |
86 } | 89 } |
87 | 90 |
88 void StreamURLRequestJob::Kill() { | 91 void StreamURLRequestJob::Kill() { |
89 net::URLRequestJob::Kill(); | 92 net::URLRequestJob::Kill(); |
90 weak_factory_.InvalidateWeakPtrs(); | 93 weak_factory_.InvalidateWeakPtrs(); |
91 ClearStream(); | 94 ClearStream(); |
92 } | 95 } |
93 | 96 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 242 } |
240 | 243 |
241 void StreamURLRequestJob::ClearStream() { | 244 void StreamURLRequestJob::ClearStream() { |
242 if (stream_.get()) { | 245 if (stream_.get()) { |
243 stream_->RemoveReadObserver(this); | 246 stream_->RemoveReadObserver(this); |
244 stream_ = NULL; | 247 stream_ = NULL; |
245 } | 248 } |
246 } | 249 } |
247 | 250 |
248 } // namespace content | 251 } // namespace content |
OLD | NEW |