| 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_channel_mojo.h" | 5 #include "ipc/mojo/ipc_channel_mojo.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (task_runner_->RunsTasksOnCurrentThread()) { | 322 if (task_runner_->RunsTasksOnCurrentThread()) { |
| 323 listener_->OnChannelError(); | 323 listener_->OnChannelError(); |
| 324 } else { | 324 } else { |
| 325 task_runner_->PostTask( | 325 task_runner_->PostTask( |
| 326 FROM_HERE, | 326 FROM_HERE, |
| 327 base::Bind(&ChannelMojo::OnPipeError, weak_factory_.GetWeakPtr())); | 327 base::Bind(&ChannelMojo::OnPipeError, weak_factory_.GetWeakPtr())); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 bool ChannelMojo::Send(Message* message) { | 331 bool ChannelMojo::Send(Message* message) { |
| 332 base::AutoLock lock(lock_); | 332 bool sent = false; |
| 333 if (!message_reader_) { | 333 { |
| 334 pending_messages_.push_back(base::WrapUnique(message)); | 334 base::AutoLock lock(lock_); |
| 335 // Counts as OK before the connection is established, but it's an | 335 if (!message_reader_) { |
| 336 // error otherwise. | 336 pending_messages_.push_back(base::WrapUnique(message)); |
| 337 return waiting_connect_; | 337 // Counts as OK before the connection is established, but it's an |
| 338 // error otherwise. |
| 339 return waiting_connect_; |
| 340 } |
| 341 |
| 342 sent = message_reader_->Send(base::WrapUnique(message)); |
| 338 } | 343 } |
| 339 | 344 |
| 340 if (!message_reader_->Send(base::WrapUnique(message))) { | 345 if (!sent) { |
| 341 OnPipeError(); | 346 OnPipeError(); |
| 342 return false; | 347 return false; |
| 343 } | 348 } |
| 344 | 349 |
| 345 return true; | 350 return true; |
| 346 } | 351 } |
| 347 | 352 |
| 348 bool ChannelMojo::IsSendThreadSafe() const { | 353 bool ChannelMojo::IsSendThreadSafe() const { |
| 349 return false; | 354 return false; |
| 350 } | 355 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 DCHECK(ok); | 436 DCHECK(ok); |
| 432 if (!ok) { | 437 if (!ok) { |
| 433 LOG(ERROR) << "Failed to add new Mojo handle."; | 438 LOG(ERROR) << "Failed to add new Mojo handle."; |
| 434 return MOJO_RESULT_UNKNOWN; | 439 return MOJO_RESULT_UNKNOWN; |
| 435 } | 440 } |
| 436 } | 441 } |
| 437 return MOJO_RESULT_OK; | 442 return MOJO_RESULT_OK; |
| 438 } | 443 } |
| 439 | 444 |
| 440 } // namespace IPC | 445 } // namespace IPC |
| OLD | NEW |