summaryrefslogtreecommitdiffstats
path: root/content/browser/streams/stream_handle_impl.cc
blob: d13bdc6a710ec28d85d7ca2cfbc2e38ad2288e06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/streams/stream_handle_impl.h"

#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "content/browser/streams/stream.h"
#include "net/http/http_response_headers.h"

namespace content {

StreamHandleImpl::StreamHandleImpl(
    const base::WeakPtr<Stream>& stream,
    const GURL& original_url,
    const std::string& mime_type,
    scoped_refptr<net::HttpResponseHeaders> response_headers)
    : stream_(stream),
      url_(stream->url()),
      original_url_(original_url),
      mime_type_(mime_type),
      response_headers_(response_headers),
      stream_message_loop_(base::MessageLoopProxy::current().get()) {}

StreamHandleImpl::~StreamHandleImpl() {
  stream_message_loop_->PostTask(FROM_HERE,
                                 base::Bind(&Stream::CloseHandle, stream_));
}

const GURL& StreamHandleImpl::GetURL() {
  return url_;
}

const GURL& StreamHandleImpl::GetOriginalURL() {
  return original_url_;
}

const std::string& StreamHandleImpl::GetMimeType() {
  return mime_type_;
}

scoped_refptr<net::HttpResponseHeaders> StreamHandleImpl::GetResponseHeaders() {
  return response_headers_;
}

}  // namespace content