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

Side by Side Diff: media/mojo/common/mojo_decoder_buffer_converter_unittest.cc

Issue 2875143002: Reduce boilerplate when creating simple mojom::URLLoaders. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/mojo/common/mojo_decoder_buffer_converter.h" 5 #include "media/mojo/common/mojo_decoder_buffer_converter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 MATCHER_P(MatchesDecoderBuffer, buffer, "") { 25 MATCHER_P(MatchesDecoderBuffer, buffer, "") {
26 DCHECK(arg); 26 DCHECK(arg);
27 return arg->MatchesForTesting(*buffer); 27 return arg->MatchesForTesting(*buffer);
28 } 28 }
29 29
30 class MojoDecoderBufferConverter { 30 class MojoDecoderBufferConverter {
31 public: 31 public:
32 MojoDecoderBufferConverter( 32 MojoDecoderBufferConverter(
33 uint32_t data_pipe_capacity_bytes = kDefaultDataPipeCapacityBytes) { 33 uint32_t data_pipe_capacity_bytes = kDefaultDataPipeCapacityBytes) {
34 MojoCreateDataPipeOptions options; 34 mojo::DataPipe data_pipe(data_pipe_capacity_bytes);
35 options.struct_size = sizeof(MojoCreateDataPipeOptions);
36 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
37 options.element_num_bytes = 1;
38 options.capacity_num_bytes = data_pipe_capacity_bytes;
39 mojo::DataPipe data_pipe(options);
40 35
41 writer = base::MakeUnique<MojoDecoderBufferWriter>( 36 writer = base::MakeUnique<MojoDecoderBufferWriter>(
42 std::move(data_pipe.producer_handle)); 37 std::move(data_pipe.producer_handle));
43 reader = base::MakeUnique<MojoDecoderBufferReader>( 38 reader = base::MakeUnique<MojoDecoderBufferReader>(
44 std::move(data_pipe.consumer_handle)); 39 std::move(data_pipe.consumer_handle));
45 } 40 }
46 41
47 void ConvertAndVerify(const scoped_refptr<DecoderBuffer>& media_buffer) { 42 void ConvertAndVerify(const scoped_refptr<DecoderBuffer>& media_buffer) {
48 base::RunLoop run_loop; 43 base::RunLoop run_loop;
49 base::MockCallback<MojoDecoderBufferReader::ReadCB> mock_cb; 44 base::MockCallback<MojoDecoderBufferReader::ReadCB> mock_cb;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 converter.writer->WriteDecoderBuffer(media_buffer); 191 converter.writer->WriteDecoderBuffer(media_buffer);
197 converter.reader->ReadDecoderBuffer(std::move(mojo_buffer), mock_cb.Get()); 192 converter.reader->ReadDecoderBuffer(std::move(mojo_buffer), mock_cb.Get());
198 193
199 // Before the entire data is transmitted, close the handle on writer side. 194 // Before the entire data is transmitted, close the handle on writer side.
200 // The reader side will get notified and report the error. 195 // The reader side will get notified and report the error.
201 converter.writer.reset(); 196 converter.writer.reset();
202 run_loop.Run(); 197 run_loop.Run();
203 } 198 }
204 199
205 } // namespace media 200 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/common/mojo_decoder_buffer_converter.cc ('k') | media/remoting/demuxer_stream_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698