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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 DVLOG(1) << __func__; 57 DVLOG(1) << __func__;
58 std::unique_ptr<mojo::DataPipe> data_pipe = CreateDataPipe(type); 58 std::unique_ptr<mojo::DataPipe> data_pipe = CreateDataPipe(type);
59 *producer_handle = std::move(data_pipe->producer_handle); 59 *producer_handle = std::move(data_pipe->producer_handle);
60 return base::WrapUnique( 60 return base::WrapUnique(
61 new MojoDecoderBufferReader(std::move(data_pipe->consumer_handle))); 61 new MojoDecoderBufferReader(std::move(data_pipe->consumer_handle)));
62 } 62 }
63 63
64 MojoDecoderBufferReader::MojoDecoderBufferReader( 64 MojoDecoderBufferReader::MojoDecoderBufferReader(
65 mojo::ScopedDataPipeConsumerHandle consumer_handle) 65 mojo::ScopedDataPipeConsumerHandle consumer_handle)
66 : consumer_handle_(std::move(consumer_handle)), 66 : consumer_handle_(std::move(consumer_handle)),
67 pipe_watcher_(FROM_HERE), 67 pipe_watcher_(FROM_HERE, mojo::Watcher::ArmingPolicy::AUTOMATIC),
68 bytes_read_(0) { 68 bytes_read_(0) {
69 DVLOG(1) << __func__; 69 DVLOG(1) << __func__;
70 70
71 MojoResult result = 71 MojoResult result =
72 pipe_watcher_.Start(consumer_handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, 72 pipe_watcher_.Start(consumer_handle_.get(), MOJO_HANDLE_SIGNAL_READABLE,
73 base::Bind(&MojoDecoderBufferReader::OnPipeReadable, 73 base::Bind(&MojoDecoderBufferReader::OnPipeReadable,
74 base::Unretained(this))); 74 base::Unretained(this)));
75 if (result != MOJO_RESULT_OK) { 75 if (result != MOJO_RESULT_OK) {
76 DVLOG(1) << __func__ 76 DVLOG(1) << __func__
77 << ": Failed to start watching the pipe. result=" << result; 77 << ": Failed to start watching the pipe. result=" << result;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DVLOG(1) << __func__; 179 DVLOG(1) << __func__;
180 std::unique_ptr<mojo::DataPipe> data_pipe = CreateDataPipe(type); 180 std::unique_ptr<mojo::DataPipe> data_pipe = CreateDataPipe(type);
181 *consumer_handle = std::move(data_pipe->consumer_handle); 181 *consumer_handle = std::move(data_pipe->consumer_handle);
182 return base::WrapUnique( 182 return base::WrapUnique(
183 new MojoDecoderBufferWriter(std::move(data_pipe->producer_handle))); 183 new MojoDecoderBufferWriter(std::move(data_pipe->producer_handle)));
184 } 184 }
185 185
186 MojoDecoderBufferWriter::MojoDecoderBufferWriter( 186 MojoDecoderBufferWriter::MojoDecoderBufferWriter(
187 mojo::ScopedDataPipeProducerHandle producer_handle) 187 mojo::ScopedDataPipeProducerHandle producer_handle)
188 : producer_handle_(std::move(producer_handle)), 188 : producer_handle_(std::move(producer_handle)),
189 pipe_watcher_(FROM_HERE), 189 pipe_watcher_(FROM_HERE, mojo::Watcher::ArmingPolicy::AUTOMATIC),
190 bytes_written_(0) { 190 bytes_written_(0) {
191 DVLOG(1) << __func__; 191 DVLOG(1) << __func__;
192 192
193 MojoResult result = 193 MojoResult result =
194 pipe_watcher_.Start(producer_handle_.get(), MOJO_HANDLE_SIGNAL_WRITABLE, 194 pipe_watcher_.Start(producer_handle_.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
195 base::Bind(&MojoDecoderBufferWriter::OnPipeWritable, 195 base::Bind(&MojoDecoderBufferWriter::OnPipeWritable,
196 base::Unretained(this))); 196 base::Unretained(this)));
197 if (result != MOJO_RESULT_OK) { 197 if (result != MOJO_RESULT_OK) {
198 DVLOG(1) << __func__ 198 DVLOG(1) << __func__
199 << ": Failed to start watching the pipe. result=" << result; 199 << ": Failed to start watching the pipe. result=" << result;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (bytes_written_ == buffer_size) { 279 if (bytes_written_ == buffer_size) {
280 media_buffer_ = nullptr; 280 media_buffer_ = nullptr;
281 bytes_written_ = 0; 281 bytes_written_ = 0;
282 } 282 }
283 } 283 }
284 284
285 return result; 285 return result;
286 } 286 }
287 287
288 } // namespace media 288 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698