OLD | NEW |
---|---|
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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 namespace { | 18 namespace { |
19 | 19 |
20 typedef std::deque<std::pair<scoped_refptr<net::IOBuffer>, size_t> > | 20 typedef std::deque<std::pair<scoped_refptr<net::IOBuffer>, size_t> > |
21 ContentVector; | 21 ContentVector; |
22 | 22 |
23 class ByteStreamReaderImpl; | 23 class ByteStreamReaderImpl; |
24 | 24 |
25 // A poor man's weak pointer; a RefCountedThreadSafe boolean that can be | 25 // This is a RefCountedThreadSafe boolean that can be cleared in an object |
Matt Giuca
2016/11/25 00:35:42
drive-by: I don't think we should lose this senten
meredithl
2016/11/27 23:49:21
Done.
| |
26 // cleared in an object destructor and accessed to check for object | 26 // destructor and accessed to check for object existence. We can't use weak |
27 // existence. We can't use weak pointers because they're tightly tied to | 27 // pointers because they're tightly tied to threads rather than task runners. |
28 // threads rather than task runners. | 28 // TODO(rdsmith): A better solution would be extending weak pointers to support |
29 // TODO(rdsmith): A better solution would be extending weak pointers | 29 // SequencedTaskRunners. |
30 // to support SequencedTaskRunners. | |
31 struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> { | 30 struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> { |
32 public: | 31 public: |
33 LifetimeFlag() : is_alive(true) { } | 32 LifetimeFlag() : is_alive(true) { } |
34 bool is_alive; | 33 bool is_alive; |
35 | 34 |
36 protected: | 35 protected: |
37 friend class base::RefCountedThreadSafe<LifetimeFlag>; | 36 friend class base::RefCountedThreadSafe<LifetimeFlag>; |
38 virtual ~LifetimeFlag() { } | 37 virtual ~LifetimeFlag() { } |
39 | 38 |
40 private: | 39 private: |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( | 455 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( |
457 output_task_runner, output_flag, buffer_size); | 456 output_task_runner, output_flag, buffer_size); |
458 | 457 |
459 in->SetPeer(out, output_task_runner, output_flag); | 458 in->SetPeer(out, output_task_runner, output_flag); |
460 out->SetPeer(in, input_task_runner, input_flag); | 459 out->SetPeer(in, input_task_runner, input_flag); |
461 input->reset(in); | 460 input->reset(in); |
462 output->reset(out); | 461 output->reset(out); |
463 } | 462 } |
464 | 463 |
465 } // namespace content | 464 } // namespace content |
OLD | NEW |