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

Side by Side Diff: content/browser/byte_stream.cc

Issue 22925003: Explain the reason why we don't have thread check in destructor of ByteStreamReader/WriterImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
« no previous file with comments | « no previous file | content/browser/download/download_resource_handler.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/byte_stream.h" 5 #include "content/browser/byte_stream.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 my_task_runner_(task_runner), 187 my_task_runner_(task_runner),
188 my_lifetime_flag_(lifetime_flag), 188 my_lifetime_flag_(lifetime_flag),
189 input_contents_size_(0), 189 input_contents_size_(0),
190 output_size_used_(0), 190 output_size_used_(0),
191 peer_(NULL) { 191 peer_(NULL) {
192 DCHECK(my_lifetime_flag_.get()); 192 DCHECK(my_lifetime_flag_.get());
193 my_lifetime_flag_->is_alive = true; 193 my_lifetime_flag_->is_alive = true;
194 } 194 }
195 195
196 ByteStreamWriterImpl::~ByteStreamWriterImpl() { 196 ByteStreamWriterImpl::~ByteStreamWriterImpl() {
197 // No RunsTasksOnCurrentThread() check to allow deleting a created writer
198 // before we start using it. Once started, should be deleted on the specified
199 // task runner.
197 my_lifetime_flag_->is_alive = false; 200 my_lifetime_flag_->is_alive = false;
198 } 201 }
199 202
200 void ByteStreamWriterImpl::SetPeer( 203 void ByteStreamWriterImpl::SetPeer(
201 ByteStreamReaderImpl* peer, 204 ByteStreamReaderImpl* peer,
202 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, 205 scoped_refptr<base::SequencedTaskRunner> peer_task_runner,
203 scoped_refptr<LifetimeFlag> peer_lifetime_flag) { 206 scoped_refptr<LifetimeFlag> peer_lifetime_flag) {
204 peer_ = peer; 207 peer_ = peer;
205 peer_task_runner_ = peer_task_runner; 208 peer_task_runner_ = peer_task_runner;
206 peer_lifetime_flag_ = peer_lifetime_flag; 209 peer_lifetime_flag_ = peer_lifetime_flag;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 my_lifetime_flag_(lifetime_flag), 319 my_lifetime_flag_(lifetime_flag),
317 received_status_(false), 320 received_status_(false),
318 status_(0), 321 status_(0),
319 unreported_consumed_bytes_(0), 322 unreported_consumed_bytes_(0),
320 peer_(NULL) { 323 peer_(NULL) {
321 DCHECK(my_lifetime_flag_.get()); 324 DCHECK(my_lifetime_flag_.get());
322 my_lifetime_flag_->is_alive = true; 325 my_lifetime_flag_->is_alive = true;
323 } 326 }
324 327
325 ByteStreamReaderImpl::~ByteStreamReaderImpl() { 328 ByteStreamReaderImpl::~ByteStreamReaderImpl() {
329 // No RunsTasksOnCurrentThread() check to allow deleting a created writer
330 // before we start using it. Once started, should be deleted on the specified
331 // task runner.
326 my_lifetime_flag_->is_alive = false; 332 my_lifetime_flag_->is_alive = false;
327 } 333 }
328 334
329 void ByteStreamReaderImpl::SetPeer( 335 void ByteStreamReaderImpl::SetPeer(
330 ByteStreamWriterImpl* peer, 336 ByteStreamWriterImpl* peer,
331 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, 337 scoped_refptr<base::SequencedTaskRunner> peer_task_runner,
332 scoped_refptr<LifetimeFlag> peer_lifetime_flag) { 338 scoped_refptr<LifetimeFlag> peer_lifetime_flag) {
333 peer_ = peer; 339 peer_ = peer;
334 peer_task_runner_ = peer_task_runner; 340 peer_task_runner_ = peer_task_runner;
335 peer_lifetime_flag_ = peer_lifetime_flag; 341 peer_lifetime_flag_ = peer_lifetime_flag;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( 459 ByteStreamReaderImpl* out = new ByteStreamReaderImpl(
454 output_task_runner, output_flag, buffer_size); 460 output_task_runner, output_flag, buffer_size);
455 461
456 in->SetPeer(out, output_task_runner, output_flag); 462 in->SetPeer(out, output_task_runner, output_flag);
457 out->SetPeer(in, input_task_runner, input_flag); 463 out->SetPeer(in, input_task_runner, input_flag);
458 input->reset(in); 464 input->reset(in);
459 output->reset(out); 465 output->reset(out);
460 } 466 }
461 467
462 } // namespace content 468 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698