| OLD | NEW |
| 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 "ipc/mojo/ipc_message_pipe_reader.h" | 5 #include "ipc/mojo/ipc_message_pipe_reader.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/location.h" | 12 #include "base/location.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 15 #include "ipc/mojo/async_handle_waiter.h" | 16 #include "ipc/mojo/async_handle_waiter.h" |
| 16 #include "ipc/mojo/ipc_channel_mojo.h" | 17 #include "ipc/mojo/ipc_channel_mojo.h" |
| 17 | 18 |
| 18 namespace IPC { | 19 namespace IPC { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 MessagePipeReader::MessagePipeReader(mojo::ScopedMessagePipeHandle handle, | 22 MessagePipeReader::MessagePipeReader(mojo::ScopedMessagePipeHandle handle, |
| 22 MessagePipeReader::Delegate* delegate) | 23 MessagePipeReader::Delegate* delegate) |
| 23 : pipe_(handle.Pass()), | 24 : pipe_(std::move(handle)), |
| 24 handle_copy_(pipe_.get().value()), | 25 handle_copy_(pipe_.get().value()), |
| 25 delegate_(delegate), | 26 delegate_(delegate), |
| 26 async_waiter_( | 27 async_waiter_(new AsyncHandleWaiter( |
| 27 new AsyncHandleWaiter(base::Bind(&MessagePipeReader::PipeIsReady, | 28 base::Bind(&MessagePipeReader::PipeIsReady, base::Unretained(this)))), |
| 28 base::Unretained(this)))), | 29 pending_send_error_(MOJO_RESULT_OK) {} |
| 29 pending_send_error_(MOJO_RESULT_OK) { | |
| 30 } | |
| 31 | 30 |
| 32 MessagePipeReader::~MessagePipeReader() { | 31 MessagePipeReader::~MessagePipeReader() { |
| 33 DCHECK(thread_checker_.CalledOnValidThread()); | 32 DCHECK(thread_checker_.CalledOnValidThread()); |
| 34 // The pipe should be closed before deletion. | 33 // The pipe should be closed before deletion. |
| 35 CHECK(!IsValid()); | 34 CHECK(!IsValid()); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void MessagePipeReader::Close() { | 37 void MessagePipeReader::Close() { |
| 39 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
| 40 async_waiter_.reset(); | 39 async_waiter_.reset(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 235 |
| 237 void MessagePipeReader::DelayedDeleter::operator()( | 236 void MessagePipeReader::DelayedDeleter::operator()( |
| 238 MessagePipeReader* ptr) const { | 237 MessagePipeReader* ptr) const { |
| 239 ptr->Close(); | 238 ptr->Close(); |
| 240 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 239 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 241 base::Bind(&DeleteNow, ptr)); | 240 base::Bind(&DeleteNow, ptr)); |
| 242 } | 241 } |
| 243 | 242 |
| 244 } // namespace internal | 243 } // namespace internal |
| 245 } // namespace IPC | 244 } // namespace IPC |
| OLD | NEW |