OLD | NEW |
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 "mojo/edk/system/channel.h" | 5 #include "mojo/edk/system/channel.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 ScopedPlatformHandleVectorPtr handles_; | 81 ScopedPlatformHandleVectorPtr handles_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(MessageView); | 83 DISALLOW_COPY_AND_ASSIGN(MessageView); |
84 }; | 84 }; |
85 | 85 |
86 class ChannelPosix : public Channel, | 86 class ChannelPosix : public Channel, |
87 public base::MessageLoop::DestructionObserver, | 87 public base::MessageLoop::DestructionObserver, |
88 public base::MessageLoopForIO::Watcher { | 88 public base::MessageLoopForIO::Watcher { |
89 public: | 89 public: |
90 ChannelPosix(Delegate* delegate, | 90 ChannelPosix(Delegate* delegate, |
91 ScopedPlatformHandle handle, | 91 ConnectionParam connection_param, |
92 scoped_refptr<base::TaskRunner> io_task_runner) | 92 scoped_refptr<base::TaskRunner> io_task_runner) |
93 : Channel(delegate), | 93 : Channel(delegate), |
94 self_(this), | 94 self_(this), |
95 handle_(std::move(handle)), | 95 handle_(connection_param.TakeChannelHandle()), |
96 io_task_runner_(io_task_runner) | 96 io_task_runner_(io_task_runner) |
97 #if defined(OS_MACOSX) | 97 #if defined(OS_MACOSX) |
98 , | 98 , |
99 handles_to_close_(new PlatformHandleVector) | 99 handles_to_close_(new PlatformHandleVector) |
100 #endif | 100 #endif |
101 { | 101 { |
| 102 CHECK(handle_.is_valid()); |
102 } | 103 } |
103 | 104 |
104 void Start() override { | 105 void Start() override { |
105 if (io_task_runner_->RunsTasksOnCurrentThread()) { | 106 if (io_task_runner_->RunsTasksOnCurrentThread()) { |
106 StartOnIOThread(); | 107 StartOnIOThread(); |
107 } else { | 108 } else { |
108 io_task_runner_->PostTask( | 109 io_task_runner_->PostTask( |
109 FROM_HERE, base::Bind(&ChannelPosix::StartOnIOThread, this)); | 110 FROM_HERE, base::Bind(&ChannelPosix::StartOnIOThread, this)); |
110 } | 111 } |
111 } | 112 } |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 #endif | 555 #endif |
555 | 556 |
556 DISALLOW_COPY_AND_ASSIGN(ChannelPosix); | 557 DISALLOW_COPY_AND_ASSIGN(ChannelPosix); |
557 }; | 558 }; |
558 | 559 |
559 } // namespace | 560 } // namespace |
560 | 561 |
561 // static | 562 // static |
562 scoped_refptr<Channel> Channel::Create( | 563 scoped_refptr<Channel> Channel::Create( |
563 Delegate* delegate, | 564 Delegate* delegate, |
564 ScopedPlatformHandle platform_handle, | 565 ConnectionParam connection_param, |
565 scoped_refptr<base::TaskRunner> io_task_runner) { | 566 scoped_refptr<base::TaskRunner> io_task_runner) { |
566 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); | 567 return new ChannelPosix(delegate, std::move(connection_param), |
| 568 io_task_runner); |
567 } | 569 } |
568 | 570 |
569 } // namespace edk | 571 } // namespace edk |
570 } // namespace mojo | 572 } // namespace mojo |
OLD | NEW |