| 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 base::LazyInstance<VistaOrHigherFunctions> g_vista_or_higher_functions = | 69 base::LazyInstance<VistaOrHigherFunctions> g_vista_or_higher_functions = |
| 70 LAZY_INSTANCE_INITIALIZER; | 70 LAZY_INSTANCE_INITIALIZER; |
| 71 | 71 |
| 72 class RawChannelWin : public RawChannel { | 72 class RawChannelWin : public RawChannel { |
| 73 public: | 73 public: |
| 74 RawChannelWin(embedder::ScopedPlatformHandle handle); | 74 RawChannelWin(embedder::ScopedPlatformHandle handle); |
| 75 virtual ~RawChannelWin(); | 75 virtual ~RawChannelWin(); |
| 76 | 76 |
| 77 // |RawChannel| public methods: | 77 // |RawChannel| public methods: |
| 78 virtual size_t GetSerializedPlatformHandleSize() const OVERRIDE; | 78 virtual size_t GetSerializedPlatformHandleSize() const override; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 // RawChannelIOHandler receives OS notifications for I/O completion. It must | 81 // RawChannelIOHandler receives OS notifications for I/O completion. It must |
| 82 // be created on the I/O thread. | 82 // be created on the I/O thread. |
| 83 // | 83 // |
| 84 // It manages its own destruction. Destruction happens on the I/O thread when | 84 // It manages its own destruction. Destruction happens on the I/O thread when |
| 85 // all the following conditions are satisfied: | 85 // all the following conditions are satisfied: |
| 86 // - |DetachFromOwnerNoLock()| has been called; | 86 // - |DetachFromOwnerNoLock()| has been called; |
| 87 // - there is no pending read; | 87 // - there is no pending read; |
| 88 // - there is no pending write. | 88 // - there is no pending write. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 bool pending_write_no_lock() const; | 104 bool pending_write_no_lock() const; |
| 105 base::MessageLoopForIO::IOContext* write_context_no_lock(); | 105 base::MessageLoopForIO::IOContext* write_context_no_lock(); |
| 106 // Instructs the object to wait for an |OnIOCompleted()| notification. | 106 // Instructs the object to wait for an |OnIOCompleted()| notification. |
| 107 void OnPendingWriteStartedNoLock(); | 107 void OnPendingWriteStartedNoLock(); |
| 108 | 108 |
| 109 // |base::MessageLoopForIO::IOHandler| implementation: | 109 // |base::MessageLoopForIO::IOHandler| implementation: |
| 110 // Must be called on the I/O thread. It could be called before or after | 110 // Must be called on the I/O thread. It could be called before or after |
| 111 // detached from the owner. | 111 // detached from the owner. |
| 112 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 112 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
| 113 DWORD bytes_transferred, | 113 DWORD bytes_transferred, |
| 114 DWORD error) OVERRIDE; | 114 DWORD error) override; |
| 115 | 115 |
| 116 // Must be called on the I/O thread under |owner_->write_lock()|. | 116 // Must be called on the I/O thread under |owner_->write_lock()|. |
| 117 // After this call, the owner must not make any further calls on this | 117 // After this call, the owner must not make any further calls on this |
| 118 // object, and therefore the object is used on the I/O thread exclusively | 118 // object, and therefore the object is used on the I/O thread exclusively |
| 119 // (if it stays alive). | 119 // (if it stays alive). |
| 120 void DetachFromOwnerNoLock(scoped_ptr<ReadBuffer> read_buffer, | 120 void DetachFromOwnerNoLock(scoped_ptr<ReadBuffer> read_buffer, |
| 121 scoped_ptr<WriteBuffer> write_buffer); | 121 scoped_ptr<WriteBuffer> write_buffer); |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 virtual ~RawChannelIOHandler(); | 124 virtual ~RawChannelIOHandler(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 // The following members must be used under |owner_->write_lock()| while the | 153 // The following members must be used under |owner_->write_lock()| while the |
| 154 // object is still attached to the owner, and only on the I/O thread | 154 // object is still attached to the owner, and only on the I/O thread |
| 155 // afterwards. | 155 // afterwards. |
| 156 bool pending_write_; | 156 bool pending_write_; |
| 157 base::MessageLoopForIO::IOContext write_context_; | 157 base::MessageLoopForIO::IOContext write_context_; |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(RawChannelIOHandler); | 159 DISALLOW_COPY_AND_ASSIGN(RawChannelIOHandler); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 // |RawChannel| private methods: | 162 // |RawChannel| private methods: |
| 163 virtual IOResult Read(size_t* bytes_read) OVERRIDE; | 163 virtual IOResult Read(size_t* bytes_read) override; |
| 164 virtual IOResult ScheduleRead() OVERRIDE; | 164 virtual IOResult ScheduleRead() override; |
| 165 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 165 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
| 166 size_t num_platform_handles, | 166 size_t num_platform_handles, |
| 167 const void* platform_handle_table) OVERRIDE; | 167 const void* platform_handle_table) override; |
| 168 virtual IOResult WriteNoLock(size_t* platform_handles_written, | 168 virtual IOResult WriteNoLock(size_t* platform_handles_written, |
| 169 size_t* bytes_written) OVERRIDE; | 169 size_t* bytes_written) override; |
| 170 virtual IOResult ScheduleWriteNoLock() OVERRIDE; | 170 virtual IOResult ScheduleWriteNoLock() override; |
| 171 virtual bool OnInit() OVERRIDE; | 171 virtual bool OnInit() override; |
| 172 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, | 172 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, |
| 173 scoped_ptr<WriteBuffer> write_buffer) OVERRIDE; | 173 scoped_ptr<WriteBuffer> write_buffer) override; |
| 174 | 174 |
| 175 // Passed to |io_handler_| during initialization. | 175 // Passed to |io_handler_| during initialization. |
| 176 embedder::ScopedPlatformHandle handle_; | 176 embedder::ScopedPlatformHandle handle_; |
| 177 | 177 |
| 178 RawChannelIOHandler* io_handler_; | 178 RawChannelIOHandler* io_handler_; |
| 179 | 179 |
| 180 const bool skip_completion_port_on_success_; | 180 const bool skip_completion_port_on_success_; |
| 181 | 181 |
| 182 DISALLOW_COPY_AND_ASSIGN(RawChannelWin); | 182 DISALLOW_COPY_AND_ASSIGN(RawChannelWin); |
| 183 }; | 183 }; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 571 |
| 572 // Static factory method declared in raw_channel.h. | 572 // Static factory method declared in raw_channel.h. |
| 573 // static | 573 // static |
| 574 scoped_ptr<RawChannel> RawChannel::Create( | 574 scoped_ptr<RawChannel> RawChannel::Create( |
| 575 embedder::ScopedPlatformHandle handle) { | 575 embedder::ScopedPlatformHandle handle) { |
| 576 return scoped_ptr<RawChannel>(new RawChannelWin(handle.Pass())); | 576 return scoped_ptr<RawChannel>(new RawChannelWin(handle.Pass())); |
| 577 } | 577 } |
| 578 | 578 |
| 579 } // namespace system | 579 } // namespace system |
| 580 } // namespace mojo | 580 } // namespace mojo |
| OLD | NEW |