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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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_url_request_job.h" 5 #include "content/browser/streams/stream_url_request_job.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "content/browser/streams/stream.h" 8 #include "content/browser/streams/stream.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 26 matching lines...) Expand all
37 net::NetworkDelegate* network_delegate, 37 net::NetworkDelegate* network_delegate,
38 scoped_refptr<Stream> stream) 38 scoped_refptr<Stream> stream)
39 : net::URLRequestJob(request, network_delegate), 39 : net::URLRequestJob(request, network_delegate),
40 weak_factory_(this), 40 weak_factory_(this),
41 stream_(stream), 41 stream_(stream),
42 headers_set_(false), 42 headers_set_(false),
43 pending_buffer_size_(0), 43 pending_buffer_size_(0),
44 total_bytes_read_(0), 44 total_bytes_read_(0),
45 max_range_(0), 45 max_range_(0),
46 request_failed_(false) { 46 request_failed_(false) {
47 DCHECK(stream_); 47 DCHECK(stream_.get());
48 stream_->SetReadObserver(this); 48 stream_->SetReadObserver(this);
49 } 49 }
50 50
51 StreamURLRequestJob::~StreamURLRequestJob() { 51 StreamURLRequestJob::~StreamURLRequestJob() {
52 ClearStream(); 52 ClearStream();
53 } 53 }
54 54
55 void StreamURLRequestJob::OnDataAvailable(Stream* stream) { 55 void StreamURLRequestJob::OnDataAvailable(Stream* stream) {
56 // Clear the IO_PENDING status. 56 // Clear the IO_PENDING status.
57 SetStatus(net::URLRequestStatus()); 57 SetStatus(net::URLRequestStatus());
58 if (pending_buffer_) { 58 if (pending_buffer_.get()) {
59 int bytes_read; 59 int bytes_read;
60 stream_->ReadRawData(pending_buffer_, pending_buffer_size_, &bytes_read); 60 stream_->ReadRawData(
61 pending_buffer_.get(), pending_buffer_size_, &bytes_read);
61 62
62 // Clear the buffers before notifying the read is complete, so that it is 63 // Clear the buffers before notifying the read is complete, so that it is
63 // safe for the observer to read. 64 // safe for the observer to read.
64 pending_buffer_ = NULL; 65 pending_buffer_ = NULL;
65 pending_buffer_size_ = 0; 66 pending_buffer_size_ = 0;
66 67
67 total_bytes_read_ += bytes_read; 68 total_bytes_read_ += bytes_read;
68 NotifyReadComplete(bytes_read); 69 NotifyReadComplete(bytes_read);
69 } 70 }
70 } 71 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 228
228 response_info_.reset(new net::HttpResponseInfo()); 229 response_info_.reset(new net::HttpResponseInfo());
229 response_info_->headers = headers; 230 response_info_->headers = headers;
230 231
231 headers_set_ = true; 232 headers_set_ = true;
232 233
233 NotifyHeadersComplete(); 234 NotifyHeadersComplete();
234 } 235 }
235 236
236 void StreamURLRequestJob::ClearStream() { 237 void StreamURLRequestJob::ClearStream() {
237 if (stream_) { 238 if (stream_.get()) {
238 stream_->RemoveReadObserver(this); 239 stream_->RemoveReadObserver(this);
239 stream_ = NULL; 240 stream_ = NULL;
240 } 241 }
241 } 242 }
242 243
243 } // namespace content 244 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/streams/stream_unittest.cc ('k') | content/browser/streams/stream_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698