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/system/raw_channel.h" | 5 #include "mojo/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 18 matching lines...) Expand all Loading... |
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 virtual ~RawChannelPosix(); |
37 | 37 |
38 // |RawChannel| public methods: | 38 // |RawChannel| public methods: |
39 virtual size_t GetSerializedPlatformHandleSize() const OVERRIDE; | 39 virtual 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 virtual void EnqueueMessageNoLock( |
46 scoped_ptr<MessageInTransit> message) OVERRIDE; | 46 scoped_ptr<MessageInTransit> message) override; |
47 // Override this to handle those extra FD-only messages. | 47 // Override this to handle those extra FD-only messages. |
48 virtual bool OnReadMessageForRawChannel( | 48 virtual bool OnReadMessageForRawChannel( |
49 const MessageInTransit::View& message_view) OVERRIDE; | 49 const MessageInTransit::View& message_view) override; |
50 virtual IOResult Read(size_t* bytes_read) OVERRIDE; | 50 virtual IOResult Read(size_t* bytes_read) override; |
51 virtual IOResult ScheduleRead() OVERRIDE; | 51 virtual IOResult ScheduleRead() override; |
52 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 52 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
53 size_t num_platform_handles, | 53 size_t num_platform_handles, |
54 const void* platform_handle_table) OVERRIDE; | 54 const void* platform_handle_table) override; |
55 virtual IOResult WriteNoLock(size_t* platform_handles_written, | 55 virtual IOResult WriteNoLock(size_t* platform_handles_written, |
56 size_t* bytes_written) OVERRIDE; | 56 size_t* bytes_written) override; |
57 virtual IOResult ScheduleWriteNoLock() OVERRIDE; | 57 virtual IOResult ScheduleWriteNoLock() override; |
58 virtual bool OnInit() OVERRIDE; | 58 virtual bool OnInit() override; |
59 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, | 59 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, |
60 scoped_ptr<WriteBuffer> write_buffer) OVERRIDE; | 60 scoped_ptr<WriteBuffer> write_buffer) override; |
61 | 61 |
62 // |base::MessageLoopForIO::Watcher| implementation: | 62 // |base::MessageLoopForIO::Watcher| implementation: |
63 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 63 virtual void OnFileCanReadWithoutBlocking(int fd) override; |
64 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 64 virtual void OnFileCanWriteWithoutBlocking(int fd) override; |
65 | 65 |
66 // Implements most of |Read()| (except for a bit of clean-up): | 66 // Implements most of |Read()| (except for a bit of clean-up): |
67 IOResult ReadImpl(size_t* bytes_read); | 67 IOResult ReadImpl(size_t* bytes_read); |
68 | 68 |
69 // Watches for |fd_| to become writable. Must be called on the I/O thread. | 69 // Watches for |fd_| to become writable. Must be called on the I/O thread. |
70 void WaitToWrite(); | 70 void WaitToWrite(); |
71 | 71 |
72 embedder::ScopedPlatformHandle fd_; | 72 embedder::ScopedPlatformHandle fd_; |
73 | 73 |
74 // The following members are only used on the I/O thread: | 74 // 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 | 477 |
478 // Static factory method declared in raw_channel.h. | 478 // Static factory method declared in raw_channel.h. |
479 // static | 479 // static |
480 scoped_ptr<RawChannel> RawChannel::Create( | 480 scoped_ptr<RawChannel> RawChannel::Create( |
481 embedder::ScopedPlatformHandle handle) { | 481 embedder::ScopedPlatformHandle handle) { |
482 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); | 482 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); |
483 } | 483 } |
484 | 484 |
485 } // namespace system | 485 } // namespace system |
486 } // namespace mojo | 486 } // namespace mojo |
OLD | NEW |