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"
8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h"
10 #include "content/browser/streams/stream.h"
16 void RunCloseListeners(const std::vector
<base::Closure
>& close_listeners
) {
17 for (size_t i
= 0; i
< close_listeners
.size(); ++i
)
18 close_listeners
[i
].Run();
23 StreamHandleImpl::StreamHandleImpl(const base::WeakPtr
<Stream
>& stream
)
26 stream_task_runner_(base::ThreadTaskRunnerHandle::Get().get()) {
29 StreamHandleImpl::~StreamHandleImpl() {
30 stream_task_runner_
->PostTaskAndReply(
31 FROM_HERE
, base::Bind(&Stream::CloseHandle
, stream_
),
32 base::Bind(&RunCloseListeners
, close_listeners_
));
35 const GURL
& StreamHandleImpl::GetURL() {
39 void StreamHandleImpl::AddCloseListener(const base::Closure
& callback
) {
40 close_listeners_
.push_back(callback
);
43 } // namespace content