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

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

Issue 15817013: Add Stream support to WebBlobRegistry and FileAPIMessageFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Redesign Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/streams/stream.h" 5 #include "content/browser/streams/stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "content/browser/streams/stream_handle_impl.h" 10 #include "content/browser/streams/stream_handle_impl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 void Stream::RemoveWriteObserver(StreamWriteObserver* observer) { 67 void Stream::RemoveWriteObserver(StreamWriteObserver* observer) {
68 DCHECK(observer == write_observer_); 68 DCHECK(observer == write_observer_);
69 write_observer_ = NULL; 69 write_observer_ = NULL;
70 } 70 }
71 71
72 void Stream::AddData(scoped_refptr<net::IOBuffer> buffer, size_t size) { 72 void Stream::AddData(scoped_refptr<net::IOBuffer> buffer, size_t size) {
73 can_add_data_ = writer_->Write(buffer, size); 73 can_add_data_ = writer_->Write(buffer, size);
74 } 74 }
75 75
76 void Stream::AddData(const char* data, size_t size) {
77 scoped_refptr<net::IOBuffer> io_buffer(new net::IOBuffer(size));
78 memcpy(io_buffer->data(), data, size);
79 can_add_data_ = writer_->Write(io_buffer, size);
80 }
81
76 void Stream::Finalize() { 82 void Stream::Finalize() {
77 writer_->Close(DOWNLOAD_INTERRUPT_REASON_NONE); 83 writer_->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
78 writer_.reset(NULL); 84 writer_.reset(NULL);
79 85
80 // Continue asynchronously. 86 // Continue asynchronously.
81 base::MessageLoopProxy::current()->PostTask( 87 base::MessageLoopProxy::current()->PostTask(
82 FROM_HERE, 88 FROM_HERE,
83 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); 89 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr()));
84 } 90 }
85 91
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (write_observer_) 146 if (write_observer_)
141 write_observer_->OnSpaceAvailable(this); 147 write_observer_->OnSpaceAvailable(this);
142 } 148 }
143 149
144 void Stream::OnDataAvailable() { 150 void Stream::OnDataAvailable() {
145 if (read_observer_) 151 if (read_observer_)
146 read_observer_->OnDataAvailable(this); 152 read_observer_->OnDataAvailable(this);
147 } 153 }
148 154
149 } // namespace content 155 } // namespace content
150
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698