| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/uio.h> | 8 #include <sys/uio.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace mojo { | 27 namespace mojo { |
| 28 namespace system { | 28 namespace system { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 class RawChannelPosix : public RawChannel, | 32 class RawChannelPosix : public RawChannel, |
| 33 public base::MessageLoopForIO::Watcher { | 33 public base::MessageLoopForIO::Watcher { |
| 34 public: | 34 public: |
| 35 explicit RawChannelPosix(embedder::ScopedPlatformHandle handle); | 35 explicit RawChannelPosix(embedder::ScopedPlatformHandle handle); |
| 36 virtual ~RawChannelPosix(); | 36 ~RawChannelPosix() override; |
| 37 | 37 |
| 38 // |RawChannel| public methods: | 38 // |RawChannel| public methods: |
| 39 virtual size_t GetSerializedPlatformHandleSize() const override; | 39 size_t GetSerializedPlatformHandleSize() const override; |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // |RawChannel| protected methods: | 42 // |RawChannel| protected methods: |
| 43 // Actually override this so that we can send multiple messages with (only) | 43 // Actually override this so that we can send multiple messages with (only) |
| 44 // FDs if necessary. | 44 // FDs if necessary. |
| 45 virtual void EnqueueMessageNoLock( | 45 void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message) override; |
| 46 scoped_ptr<MessageInTransit> message) override; | |
| 47 // Override this to handle those extra FD-only messages. | 46 // Override this to handle those extra FD-only messages. |
| 48 virtual bool OnReadMessageForRawChannel( | 47 bool OnReadMessageForRawChannel( |
| 49 const MessageInTransit::View& message_view) override; | 48 const MessageInTransit::View& message_view) override; |
| 50 virtual IOResult Read(size_t* bytes_read) override; | 49 IOResult Read(size_t* bytes_read) override; |
| 51 virtual IOResult ScheduleRead() override; | 50 IOResult ScheduleRead() override; |
| 52 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 51 embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
| 53 size_t num_platform_handles, | 52 size_t num_platform_handles, |
| 54 const void* platform_handle_table) override; | 53 const void* platform_handle_table) override; |
| 55 virtual IOResult WriteNoLock(size_t* platform_handles_written, | 54 IOResult WriteNoLock(size_t* platform_handles_written, |
| 56 size_t* bytes_written) override; | 55 size_t* bytes_written) override; |
| 57 virtual IOResult ScheduleWriteNoLock() override; | 56 IOResult ScheduleWriteNoLock() override; |
| 58 virtual bool OnInit() override; | 57 bool OnInit() override; |
| 59 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, | 58 void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, |
| 60 scoped_ptr<WriteBuffer> write_buffer) override; | 59 scoped_ptr<WriteBuffer> write_buffer) override; |
| 61 | 60 |
| 62 // |base::MessageLoopForIO::Watcher| implementation: | 61 // |base::MessageLoopForIO::Watcher| implementation: |
| 63 virtual void OnFileCanReadWithoutBlocking(int fd) override; | 62 void OnFileCanReadWithoutBlocking(int fd) override; |
| 64 virtual void OnFileCanWriteWithoutBlocking(int fd) override; | 63 void OnFileCanWriteWithoutBlocking(int fd) override; |
| 65 | 64 |
| 66 // Implements most of |Read()| (except for a bit of clean-up): | 65 // Implements most of |Read()| (except for a bit of clean-up): |
| 67 IOResult ReadImpl(size_t* bytes_read); | 66 IOResult ReadImpl(size_t* bytes_read); |
| 68 | 67 |
| 69 // Watches for |fd_| to become writable. Must be called on the I/O thread. | 68 // Watches for |fd_| to become writable. Must be called on the I/O thread. |
| 70 void WaitToWrite(); | 69 void WaitToWrite(); |
| 71 | 70 |
| 72 embedder::ScopedPlatformHandle fd_; | 71 embedder::ScopedPlatformHandle fd_; |
| 73 | 72 |
| 74 // The following members are only used on the I/O thread: | 73 // The following members are only used on the I/O thread: |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 476 |
| 478 // Static factory method declared in raw_channel.h. | 477 // Static factory method declared in raw_channel.h. |
| 479 // static | 478 // static |
| 480 scoped_ptr<RawChannel> RawChannel::Create( | 479 scoped_ptr<RawChannel> RawChannel::Create( |
| 481 embedder::ScopedPlatformHandle handle) { | 480 embedder::ScopedPlatformHandle handle) { |
| 482 return make_scoped_ptr(new RawChannelPosix(handle.Pass())); | 481 return make_scoped_ptr(new RawChannelPosix(handle.Pass())); |
| 483 } | 482 } |
| 484 | 483 |
| 485 } // namespace system | 484 } // namespace system |
| 486 } // namespace mojo | 485 } // namespace mojo |
| OLD | NEW |