Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / streams / stream_handle_impl.cc
blob6ff49621b57f10744cc10fe875906da362bc97ca
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
3 // found in the LICENSE file.
5 #include "content/browser/streams/stream_handle_impl.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "content/browser/streams/stream.h"
11 #include "net/http/http_response_headers.h"
13 namespace content {
15 namespace {
17 void RunCloseListeners(const std::vector<base::Closure>& close_listeners) {
18 for (size_t i = 0; i < close_listeners.size(); ++i)
19 close_listeners[i].Run();
22 } // namespace
24 StreamHandleImpl::StreamHandleImpl(
25 const base::WeakPtr<Stream>& stream,
26 const GURL& original_url,
27 const std::string& mime_type,
28 scoped_refptr<net::HttpResponseHeaders> response_headers)
29 : stream_(stream),
30 url_(stream->url()),
31 original_url_(original_url),
32 mime_type_(mime_type),
33 response_headers_(response_headers),
34 stream_message_loop_(base::MessageLoopProxy::current().get()) {}
36 StreamHandleImpl::~StreamHandleImpl() {
37 stream_message_loop_->PostTaskAndReply(FROM_HERE,
38 base::Bind(&Stream::CloseHandle, stream_),
39 base::Bind(&RunCloseListeners, close_listeners_));
42 const GURL& StreamHandleImpl::GetURL() {
43 return url_;
46 const GURL& StreamHandleImpl::GetOriginalURL() {
47 return original_url_;
50 const std::string& StreamHandleImpl::GetMimeType() {
51 return mime_type_;
54 scoped_refptr<net::HttpResponseHeaders> StreamHandleImpl::GetResponseHeaders() {
55 return response_headers_;
58 void StreamHandleImpl::AddCloseListener(const base::Closure& callback) {
59 close_listeners_.push_back(callback);
62 } // namespace content