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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 size_t buffer_size); | 50 size_t buffer_size); |
51 virtual ~ByteStreamWriterImpl(); | 51 virtual ~ByteStreamWriterImpl(); |
52 | 52 |
53 // Must be called before any operations are performed. | 53 // Must be called before any operations are performed. |
54 void SetPeer(ByteStreamReaderImpl* peer, | 54 void SetPeer(ByteStreamReaderImpl* peer, |
55 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, | 55 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, |
56 scoped_refptr<LifetimeFlag> peer_lifetime_flag); | 56 scoped_refptr<LifetimeFlag> peer_lifetime_flag); |
57 | 57 |
58 // Overridden from ByteStreamWriter. | 58 // Overridden from ByteStreamWriter. |
59 virtual bool Write(scoped_refptr<net::IOBuffer> buffer, | 59 virtual bool Write(scoped_refptr<net::IOBuffer> buffer, |
60 size_t byte_count) OVERRIDE; | 60 size_t byte_count) override; |
61 virtual void Flush() OVERRIDE; | 61 virtual void Flush() override; |
62 virtual void Close(int status) OVERRIDE; | 62 virtual void Close(int status) override; |
63 virtual void RegisterCallback(const base::Closure& source_callback) OVERRIDE; | 63 virtual void RegisterCallback(const base::Closure& source_callback) override; |
64 virtual size_t GetTotalBufferedBytes() const OVERRIDE; | 64 virtual size_t GetTotalBufferedBytes() const override; |
65 | 65 |
66 // PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|. | 66 // PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|. |
67 static void UpdateWindow(scoped_refptr<LifetimeFlag> lifetime_flag, | 67 static void UpdateWindow(scoped_refptr<LifetimeFlag> lifetime_flag, |
68 ByteStreamWriterImpl* target, | 68 ByteStreamWriterImpl* target, |
69 size_t bytes_consumed); | 69 size_t bytes_consumed); |
70 | 70 |
71 private: | 71 private: |
72 // Called from UpdateWindow when object existence has been validated. | 72 // Called from UpdateWindow when object existence has been validated. |
73 void UpdateWindowInternal(size_t bytes_consumed); | 73 void UpdateWindowInternal(size_t bytes_consumed); |
74 | 74 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 size_t buffer_size); | 110 size_t buffer_size); |
111 virtual ~ByteStreamReaderImpl(); | 111 virtual ~ByteStreamReaderImpl(); |
112 | 112 |
113 // Must be called before any operations are performed. | 113 // Must be called before any operations are performed. |
114 void SetPeer(ByteStreamWriterImpl* peer, | 114 void SetPeer(ByteStreamWriterImpl* peer, |
115 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, | 115 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, |
116 scoped_refptr<LifetimeFlag> peer_lifetime_flag); | 116 scoped_refptr<LifetimeFlag> peer_lifetime_flag); |
117 | 117 |
118 // Overridden from ByteStreamReader. | 118 // Overridden from ByteStreamReader. |
119 virtual StreamState Read(scoped_refptr<net::IOBuffer>* data, | 119 virtual StreamState Read(scoped_refptr<net::IOBuffer>* data, |
120 size_t* length) OVERRIDE; | 120 size_t* length) override; |
121 virtual int GetStatus() const OVERRIDE; | 121 virtual int GetStatus() const override; |
122 virtual void RegisterCallback(const base::Closure& sink_callback) OVERRIDE; | 122 virtual void RegisterCallback(const base::Closure& sink_callback) override; |
123 | 123 |
124 // PostTask target from |ByteStreamWriterImpl::Write| and | 124 // PostTask target from |ByteStreamWriterImpl::Write| and |
125 // |ByteStreamWriterImpl::Close|. | 125 // |ByteStreamWriterImpl::Close|. |
126 // Receive data from our peer. | 126 // Receive data from our peer. |
127 // static because it may be called after the object it is targeting | 127 // static because it may be called after the object it is targeting |
128 // has been destroyed. It may not access |*target| | 128 // has been destroyed. It may not access |*target| |
129 // if |*object_lifetime_flag| is false. | 129 // if |*object_lifetime_flag| is false. |
130 static void TransferData( | 130 static void TransferData( |
131 scoped_refptr<LifetimeFlag> object_lifetime_flag, | 131 scoped_refptr<LifetimeFlag> object_lifetime_flag, |
132 ByteStreamReaderImpl* target, | 132 ByteStreamReaderImpl* target, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( | 459 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( |
460 output_task_runner, output_flag, buffer_size); | 460 output_task_runner, output_flag, buffer_size); |
461 | 461 |
462 in->SetPeer(out, output_task_runner, output_flag); | 462 in->SetPeer(out, output_task_runner, output_flag); |
463 out->SetPeer(in, input_task_runner, input_flag); | 463 out->SetPeer(in, input_task_runner, input_flag); |
464 input->reset(in); | 464 input->reset(in); |
465 output->reset(out); | 465 output->reset(out); |
466 } | 466 } |
467 | 467 |
468 } // namespace content | 468 } // namespace content |
OLD | NEW |