Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "content/browser/streams/stream_handle_impl.h" | |
| 6 | |
| 7 #include "content/browser/streams/stream.h" | |
| 8 #include "content/public/browser/browser_thread.h" | |
| 9 | |
| 10 namespace content { | |
| 11 | |
| 12 StreamHandleImpl::StreamHandleImpl(base::WeakPtr<Stream> stream) | |
|
darin (slow to review)
2013/03/19 06:12:51
nit: we normally pass WeakPtr using |const WeakPtr
Zachary Kuznia
2013/03/19 06:59:35
Done.
| |
| 13 : stream_(stream), | |
| 14 url_(stream->url()), | |
| 15 stream_message_loop_(base::MessageLoopProxy::current()), | |
| 16 callback_message_loop_(NULL) { | |
| 17 } | |
| 18 | |
| 19 StreamHandleImpl::~StreamHandleImpl() { | |
| 20 stream_message_loop_->PostTask(FROM_HERE, | |
| 21 base::Bind(&Stream::CloseHandle, stream_)); | |
| 22 } | |
| 23 | |
| 24 void StreamHandleImpl::SendCloseEvent() { | |
|
darin (slow to review)
2013/03/19 06:12:51
nit: Stream::CloseHandle and StreamHandle::SendClo
Zachary Kuznia
2013/03/19 06:59:35
Done.
| |
| 25 base::AutoLock lock(callback_lock_); | |
| 26 stream_.reset(); | |
| 27 if (!callback_.is_null()) { | |
| 28 CHECK(callback_message_loop_); | |
| 29 callback_message_loop_->PostTask(FROM_HERE, callback_); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 const GURL& StreamHandleImpl::GetUrl() { | |
| 34 return url_; | |
| 35 } | |
| 36 | |
| 37 void StreamHandleImpl::RegisterCloseCallback(const base::Closure& callback) { | |
| 38 base::AutoLock lock(callback_lock_); | |
| 39 if (stream_) { | |
| 40 callback_ = callback; | |
| 41 callback_message_loop_ = base::MessageLoopProxy::current(); | |
| 42 } else { | |
| 43 // If the stream is NULL, the close event has already been sent. | |
| 44 base::MessageLoopProxy::current()->PostTask(FROM_HERE, callback); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 } // namespace content | |
| OLD | NEW |