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

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

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « content/browser/browser_url_handler_impl.h ('k') | content/browser/cert_store_impl.h » ('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 30 matching lines...) Expand all
41 }; 41 };
42 42
43 // For both ByteStreamWriterImpl and ByteStreamReaderImpl, Construction and 43 // For both ByteStreamWriterImpl and ByteStreamReaderImpl, Construction and
44 // SetPeer may happen anywhere; all other operations on each class must 44 // SetPeer may happen anywhere; all other operations on each class must
45 // happen in the context of their SequencedTaskRunner. 45 // happen in the context of their SequencedTaskRunner.
46 class ByteStreamWriterImpl : public ByteStreamWriter { 46 class ByteStreamWriterImpl : public ByteStreamWriter {
47 public: 47 public:
48 ByteStreamWriterImpl(scoped_refptr<base::SequencedTaskRunner> task_runner, 48 ByteStreamWriterImpl(scoped_refptr<base::SequencedTaskRunner> task_runner,
49 scoped_refptr<LifetimeFlag> lifetime_flag, 49 scoped_refptr<LifetimeFlag> lifetime_flag,
50 size_t buffer_size); 50 size_t buffer_size);
51 virtual ~ByteStreamWriterImpl(); 51 ~ByteStreamWriterImpl() override;
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 bool Write(scoped_refptr<net::IOBuffer> buffer, size_t byte_count) override;
60 size_t byte_count) override; 60 void Flush() override;
61 virtual void Flush() override; 61 void Close(int status) override;
62 virtual void Close(int status) override; 62 void RegisterCallback(const base::Closure& source_callback) override;
63 virtual void RegisterCallback(const base::Closure& source_callback) override; 63 size_t GetTotalBufferedBytes() const override;
64 virtual size_t GetTotalBufferedBytes() const override;
65 64
66 // PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|. 65 // PostTask target from |ByteStreamReaderImpl::MaybeUpdateInput|.
67 static void UpdateWindow(scoped_refptr<LifetimeFlag> lifetime_flag, 66 static void UpdateWindow(scoped_refptr<LifetimeFlag> lifetime_flag,
68 ByteStreamWriterImpl* target, 67 ByteStreamWriterImpl* target,
69 size_t bytes_consumed); 68 size_t bytes_consumed);
70 69
71 private: 70 private:
72 // Called from UpdateWindow when object existence has been validated. 71 // Called from UpdateWindow when object existence has been validated.
73 void UpdateWindowInternal(size_t bytes_consumed); 72 void UpdateWindowInternal(size_t bytes_consumed);
74 73
(...skipping 26 matching lines...) Expand all
101 // Only valid to access on peer_task_runner_ if 100 // Only valid to access on peer_task_runner_ if
102 // |*peer_lifetime_flag_ == true| 101 // |*peer_lifetime_flag_ == true|
103 ByteStreamReaderImpl* peer_; 102 ByteStreamReaderImpl* peer_;
104 }; 103 };
105 104
106 class ByteStreamReaderImpl : public ByteStreamReader { 105 class ByteStreamReaderImpl : public ByteStreamReader {
107 public: 106 public:
108 ByteStreamReaderImpl(scoped_refptr<base::SequencedTaskRunner> task_runner, 107 ByteStreamReaderImpl(scoped_refptr<base::SequencedTaskRunner> task_runner,
109 scoped_refptr<LifetimeFlag> lifetime_flag, 108 scoped_refptr<LifetimeFlag> lifetime_flag,
110 size_t buffer_size); 109 size_t buffer_size);
111 virtual ~ByteStreamReaderImpl(); 110 ~ByteStreamReaderImpl() override;
112 111
113 // Must be called before any operations are performed. 112 // Must be called before any operations are performed.
114 void SetPeer(ByteStreamWriterImpl* peer, 113 void SetPeer(ByteStreamWriterImpl* peer,
115 scoped_refptr<base::SequencedTaskRunner> peer_task_runner, 114 scoped_refptr<base::SequencedTaskRunner> peer_task_runner,
116 scoped_refptr<LifetimeFlag> peer_lifetime_flag); 115 scoped_refptr<LifetimeFlag> peer_lifetime_flag);
117 116
118 // Overridden from ByteStreamReader. 117 // Overridden from ByteStreamReader.
119 virtual StreamState Read(scoped_refptr<net::IOBuffer>* data, 118 StreamState Read(scoped_refptr<net::IOBuffer>* data, size_t* length) override;
120 size_t* length) override; 119 int GetStatus() const override;
121 virtual int GetStatus() const override; 120 void RegisterCallback(const base::Closure& sink_callback) override;
122 virtual void RegisterCallback(const base::Closure& sink_callback) override;
123 121
124 // PostTask target from |ByteStreamWriterImpl::Write| and 122 // PostTask target from |ByteStreamWriterImpl::Write| and
125 // |ByteStreamWriterImpl::Close|. 123 // |ByteStreamWriterImpl::Close|.
126 // Receive data from our peer. 124 // Receive data from our peer.
127 // static because it may be called after the object it is targeting 125 // static because it may be called after the object it is targeting
128 // has been destroyed. It may not access |*target| 126 // has been destroyed. It may not access |*target|
129 // if |*object_lifetime_flag| is false. 127 // if |*object_lifetime_flag| is false.
130 static void TransferData( 128 static void TransferData(
131 scoped_refptr<LifetimeFlag> object_lifetime_flag, 129 scoped_refptr<LifetimeFlag> object_lifetime_flag,
132 ByteStreamReaderImpl* target, 130 ByteStreamReaderImpl* target,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 ByteStreamReaderImpl* out = new ByteStreamReaderImpl( 457 ByteStreamReaderImpl* out = new ByteStreamReaderImpl(
460 output_task_runner, output_flag, buffer_size); 458 output_task_runner, output_flag, buffer_size);
461 459
462 in->SetPeer(out, output_task_runner, output_flag); 460 in->SetPeer(out, output_task_runner, output_flag);
463 out->SetPeer(in, input_task_runner, input_flag); 461 out->SetPeer(in, input_task_runner, input_flag);
464 input->reset(in); 462 input->reset(in);
465 output->reset(out); 463 output->reset(out);
466 } 464 }
467 465
468 } // namespace content 466 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_url_handler_impl.h ('k') | content/browser/cert_store_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698