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 // A makeshift weak pointer; a RefCountedThreadSafe boolean that can be cleared |
26 // cleared in an object destructor and accessed to check for object | 26 // in an object destructor and accessed to check for object existence. We can't |
27 // existence. We can't use weak pointers because they're tightly tied to | 27 // use weak pointers because they're tightly tied to threads rather than task |
28 // threads rather than task runners. | 28 // runners. |
29 // TODO(rdsmith): A better solution would be extending weak pointers | 29 // TODO(rdsmith): A better solution would be extending weak pointers |
30 // to support SequencedTaskRunners. | 30 // to support SequencedTaskRunners. |
31 struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> { | 31 struct LifetimeFlag : public base::RefCountedThreadSafe<LifetimeFlag> { |
32 public: | 32 public: |
33 LifetimeFlag() : is_alive(true) { } | 33 LifetimeFlag() : is_alive(true) {} |
Matt Giuca
2016/11/28 00:51:34
nit: There's some more unnecessary formatting chan
meredithl
2016/11/28 01:13:18
My bad, I accidentally ran clang in sublime over t
meredithl
2016/11/28 01:13:18
Done.
| |
34 bool is_alive; | 34 bool is_alive; |
35 | 35 |
36 protected: | 36 protected: |
37 friend class base::RefCountedThreadSafe<LifetimeFlag>; | 37 friend class base::RefCountedThreadSafe<LifetimeFlag>; |
38 virtual ~LifetimeFlag() { } | 38 virtual ~LifetimeFlag() { } |
39 | 39 |
40 private: | 40 private: |
41 DISALLOW_COPY_AND_ASSIGN(LifetimeFlag); | 41 DISALLOW_COPY_AND_ASSIGN(LifetimeFlag); |
42 }; | 42 }; |
43 | 43 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( | 456 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( |
457 output_task_runner, output_flag, buffer_size); | 457 output_task_runner, output_flag, buffer_size); |
458 | 458 |
459 in->SetPeer(out, output_task_runner, output_flag); | 459 in->SetPeer(out, output_task_runner, output_flag); |
460 out->SetPeer(in, input_task_runner, input_flag); | 460 out->SetPeer(in, input_task_runner, input_flag); |
461 input->reset(in); | 461 input->reset(in); |
462 output->reset(out); | 462 output->reset(out); |
463 } | 463 } |
464 | 464 |
465 } // namespace content | 465 } // namespace content |
OLD | NEW |