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

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

Issue 185663002: Pass http response headers to the streamsPrivate API callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 buf_size : remaining_bytes; 151 buf_size : remaining_bytes;
152 memcpy(buf->data(), data_->data() + data_bytes_read_, to_read); 152 memcpy(buf->data(), data_->data() + data_bytes_read_, to_read);
153 data_bytes_read_ += to_read; 153 data_bytes_read_ += to_read;
154 if (data_bytes_read_ >= data_length_) 154 if (data_bytes_read_ >= data_length_)
155 ClearBuffer(); 155 ClearBuffer();
156 156
157 *bytes_read = to_read; 157 *bytes_read = to_read;
158 return STREAM_HAS_DATA; 158 return STREAM_HAS_DATA;
159 } 159 }
160 160
161 scoped_ptr<StreamHandle> Stream::CreateHandle(const GURL& original_url, 161 scoped_ptr<StreamHandle> Stream::CreateHandle(
162 const std::string& mime_type) { 162 const GURL& original_url,
163 const std::string& mime_type,
164 const std::string& response_headers) {
163 CHECK(!stream_handle_); 165 CHECK(!stream_handle_);
164 stream_handle_ = new StreamHandleImpl(weak_ptr_factory_.GetWeakPtr(), 166 stream_handle_ = new StreamHandleImpl(weak_ptr_factory_.GetWeakPtr(),
165 original_url, 167 original_url,
166 mime_type); 168 mime_type,
169 response_headers);
167 return scoped_ptr<StreamHandle>(stream_handle_).Pass(); 170 return scoped_ptr<StreamHandle>(stream_handle_).Pass();
168 } 171 }
169 172
170 void Stream::CloseHandle() { 173 void Stream::CloseHandle() {
171 // Prevent deletion until this function ends. 174 // Prevent deletion until this function ends.
172 scoped_refptr<Stream> ref(this); 175 scoped_refptr<Stream> ref(this);
173 176
174 CHECK(stream_handle_); 177 CHECK(stream_handle_);
175 stream_handle_ = NULL; 178 stream_handle_ = NULL;
176 registry_->UnregisterStream(url()); 179 registry_->UnregisterStream(url());
(...skipping 12 matching lines...) Expand all
189 read_observer_->OnDataAvailable(this); 192 read_observer_->OnDataAvailable(this);
190 } 193 }
191 194
192 void Stream::ClearBuffer() { 195 void Stream::ClearBuffer() {
193 data_ = NULL; 196 data_ = NULL;
194 data_length_ = 0; 197 data_length_ = 0;
195 data_bytes_read_ = 0; 198 data_bytes_read_ = 0;
196 } 199 }
197 200
198 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698