Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: ipc/mojo/ipc_channel_mojo.cc

Issue 555503007: Cleanup: Get rid of OS_WIN/OS_POSIX ifdefs from MojoApplication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "ipc/ipc_listener.h" 10 #include "ipc/ipc_listener.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 listener, 65 listener,
66 io_thread_task_runner_).PassAs<Channel>(); 66 io_thread_task_runner_).PassAs<Channel>();
67 } 67 }
68 68
69 private: 69 private:
70 ChannelHandle channel_handle_; 70 ChannelHandle channel_handle_;
71 Channel::Mode mode_; 71 Channel::Mode mode_;
72 scoped_refptr<base::TaskRunner> io_thread_task_runner_; 72 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
73 }; 73 };
74 74
75 mojo::embedder::PlatformHandle ToPlatformHandle(
76 const ChannelHandle& handle) {
77 #if defined(OS_POSIX) && !defined(OS_NACL)
78 return mojo::embedder::PlatformHandle(handle.socket.fd);
79 #elif defined(OS_WIN)
80 return mojo::embedder::PlatformHandle(handle.pipe.handle);
81 #else
82 #error "Unsupported Platform!"
83 #endif
84 }
85
86 } // namespace 75 } // namespace
87 76
88 //------------------------------------------------------------------------------ 77 //------------------------------------------------------------------------------
89 78
90 void ChannelMojo::ChannelInfoDeleter::operator()( 79 void ChannelMojo::ChannelInfoDeleter::operator()(
91 mojo::embedder::ChannelInfo* ptr) const { 80 mojo::embedder::ChannelInfo* ptr) const {
92 mojo::embedder::DestroyChannelOnIOThread(ptr); 81 mojo::embedder::DestroyChannelOnIOThread(ptr);
93 } 82 }
94 83
95 //------------------------------------------------------------------------------ 84 //------------------------------------------------------------------------------
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 122
134 ChannelMojo::~ChannelMojo() { 123 ChannelMojo::~ChannelMojo() {
135 Close(); 124 Close();
136 } 125 }
137 126
138 void ChannelMojo::InitOnIOThread() { 127 void ChannelMojo::InitOnIOThread() {
139 mojo::embedder::ChannelInfo* channel_info; 128 mojo::embedder::ChannelInfo* channel_info;
140 mojo::ScopedMessagePipeHandle control_pipe = 129 mojo::ScopedMessagePipeHandle control_pipe =
141 mojo::embedder::CreateChannelOnIOThread( 130 mojo::embedder::CreateChannelOnIOThread(
142 mojo::embedder::ScopedPlatformHandle( 131 mojo::embedder::ScopedPlatformHandle(
143 ToPlatformHandle(bootstrap_->TakePipeHandle())), 132 mojo::embedder::PlatformHandle(
133 bootstrap_->TakePipeHandle().platform_file())),
144 &channel_info); 134 &channel_info);
145 channel_info_.reset(channel_info); 135 channel_info_.reset(channel_info);
146 136
147 switch (mode_) { 137 switch (mode_) {
148 case MODE_SERVER: 138 case MODE_SERVER:
149 control_reader_.reset( 139 control_reader_.reset(
150 new internal::ServerControlReader(control_pipe.Pass(), this)); 140 new internal::ServerControlReader(control_pipe.Pass(), this));
151 break; 141 break;
152 case MODE_CLIENT: 142 case MODE_CLIENT:
153 control_reader_.reset( 143 control_reader_.reset(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 handles->push_back(wrapped_handle); 275 handles->push_back(wrapped_handle);
286 } 276 }
287 } 277 }
288 278
289 return MOJO_RESULT_OK; 279 return MOJO_RESULT_OK;
290 } 280 }
291 281
292 #endif // defined(OS_POSIX) && !defined(OS_NACL) 282 #endif // defined(OS_POSIX) && !defined(OS_NACL)
293 283
294 } // namespace IPC 284 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698