| 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_handle_impl.h" | 5 #include "content/browser/streams/stream_handle_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "content/browser/streams/stream.h" | 10 #include "content/browser/streams/stream.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 StreamHandleImpl::StreamHandleImpl( | 24 StreamHandleImpl::StreamHandleImpl( |
| 25 const base::WeakPtr<Stream>& stream, | 25 const base::WeakPtr<Stream>& stream, |
| 26 const GURL& original_url, | 26 const GURL& original_url, |
| 27 const std::string& mime_type, | 27 const std::string& mime_type, |
| 28 scoped_refptr<net::HttpResponseHeaders> response_headers) | 28 scoped_refptr<net::HttpResponseHeaders> response_headers) |
| 29 : stream_(stream), | 29 : stream_(stream), |
| 30 url_(stream->url()), | 30 url_(stream->url()), |
| 31 original_url_(original_url), | 31 original_url_(original_url), |
| 32 mime_type_(mime_type), | 32 mime_type_(mime_type), |
| 33 // Make a copy of the response headers so it is safe to pass this across | 33 response_headers_(NULL), |
| 34 // threads. | 34 stream_message_loop_(base::MessageLoopProxy::current().get()) { |
| 35 response_headers_( | 35 // Make a copy of the response headers so it is safe to pass this across |
| 36 new net::HttpResponseHeaders(response_headers->raw_headers())), | 36 // threads. |
| 37 stream_message_loop_(base::MessageLoopProxy::current().get()) {} | 37 if (response_headers.get()) { |
| 38 response_headers_ = |
| 39 new net::HttpResponseHeaders(response_headers->raw_headers()); |
| 40 } |
| 41 } |
| 38 | 42 |
| 39 StreamHandleImpl::~StreamHandleImpl() { | 43 StreamHandleImpl::~StreamHandleImpl() { |
| 40 stream_message_loop_->PostTaskAndReply(FROM_HERE, | 44 stream_message_loop_->PostTaskAndReply(FROM_HERE, |
| 41 base::Bind(&Stream::CloseHandle, stream_), | 45 base::Bind(&Stream::CloseHandle, stream_), |
| 42 base::Bind(&RunCloseListeners, close_listeners_)); | 46 base::Bind(&RunCloseListeners, close_listeners_)); |
| 43 } | 47 } |
| 44 | 48 |
| 45 const GURL& StreamHandleImpl::GetURL() { | 49 const GURL& StreamHandleImpl::GetURL() { |
| 46 return url_; | 50 return url_; |
| 47 } | 51 } |
| 48 | 52 |
| 49 const GURL& StreamHandleImpl::GetOriginalURL() { | 53 const GURL& StreamHandleImpl::GetOriginalURL() { |
| 50 return original_url_; | 54 return original_url_; |
| 51 } | 55 } |
| 52 | 56 |
| 53 const std::string& StreamHandleImpl::GetMimeType() { | 57 const std::string& StreamHandleImpl::GetMimeType() { |
| 54 return mime_type_; | 58 return mime_type_; |
| 55 } | 59 } |
| 56 | 60 |
| 57 scoped_refptr<net::HttpResponseHeaders> StreamHandleImpl::GetResponseHeaders() { | 61 scoped_refptr<net::HttpResponseHeaders> StreamHandleImpl::GetResponseHeaders() { |
| 58 return response_headers_; | 62 return response_headers_; |
| 59 } | 63 } |
| 60 | 64 |
| 61 void StreamHandleImpl::AddCloseListener(const base::Closure& callback) { | 65 void StreamHandleImpl::AddCloseListener(const base::Closure& callback) { |
| 62 close_listeners_.push_back(callback); | 66 close_listeners_.push_back(callback); |
| 63 } | 67 } |
| 64 | 68 |
| 65 } // namespace content | 69 } // namespace content |
| OLD | NEW |