Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/browser/streams/stream_handle_impl.cc

Issue 12645004: Add Resource Handler for creating Streams to forward to extensions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make sure things are called on the right thread. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698