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

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

Issue 519533002: Initial PlzNavigate RDH-side logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 2 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
« no previous file with comments | « content/browser/streams/stream.h ('k') | content/browser/streams/stream_handle_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/values.h" 10 #include "base/values.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 buf_size : remaining_bytes; 153 buf_size : remaining_bytes;
154 memcpy(buf->data(), data_->data() + data_bytes_read_, to_read); 154 memcpy(buf->data(), data_->data() + data_bytes_read_, to_read);
155 data_bytes_read_ += to_read; 155 data_bytes_read_ += to_read;
156 if (data_bytes_read_ >= data_length_) 156 if (data_bytes_read_ >= data_length_)
157 ClearBuffer(); 157 ClearBuffer();
158 158
159 *bytes_read = to_read; 159 *bytes_read = to_read;
160 return STREAM_HAS_DATA; 160 return STREAM_HAS_DATA;
161 } 161 }
162 162
163 scoped_ptr<StreamHandle> Stream::CreateHandle( 163 scoped_ptr<StreamHandle> Stream::CreateHandle() {
164 const GURL& original_url,
165 const std::string& mime_type,
166 scoped_refptr<net::HttpResponseHeaders> response_headers) {
167 CHECK(!stream_handle_); 164 CHECK(!stream_handle_);
168 stream_handle_ = new StreamHandleImpl(weak_ptr_factory_.GetWeakPtr(), 165 stream_handle_ = new StreamHandleImpl(weak_ptr_factory_.GetWeakPtr());
169 original_url,
170 mime_type,
171 response_headers);
172 return scoped_ptr<StreamHandle>(stream_handle_).Pass(); 166 return scoped_ptr<StreamHandle>(stream_handle_).Pass();
173 } 167 }
174 168
175 void Stream::CloseHandle() { 169 void Stream::CloseHandle() {
176 // Prevent deletion until this function ends. 170 // Prevent deletion until this function ends.
177 scoped_refptr<Stream> ref(this); 171 scoped_refptr<Stream> ref(this);
178 172
179 CHECK(stream_handle_); 173 CHECK(stream_handle_);
180 stream_handle_ = NULL; 174 stream_handle_ = NULL;
181 registry_->UnregisterStream(url()); 175 registry_->UnregisterStream(url());
(...skipping 12 matching lines...) Expand all
194 read_observer_->OnDataAvailable(this); 188 read_observer_->OnDataAvailable(this);
195 } 189 }
196 190
197 void Stream::ClearBuffer() { 191 void Stream::ClearBuffer() {
198 data_ = NULL; 192 data_ = NULL;
199 data_length_ = 0; 193 data_length_ = 0;
200 data_bytes_read_ = 0; 194 data_bytes_read_ = 0;
201 } 195 }
202 196
203 } // namespace content 197 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/streams/stream.h ('k') | content/browser/streams/stream_handle_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698