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

Side by Side Diff: mojo/edk/system/raw_channel_posix.cc

Issue 1483823004: EDK: Move {platform_handle,scoped_platform_handle}.* to //mojo/edk/platform. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « mojo/edk/system/raw_channel.cc ('k') | mojo/edk/system/raw_channel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <algorithm> 11 #include <algorithm>
12 #include <deque> 12 #include <deque>
13 #include <iterator> 13 #include <iterator>
14 #include <memory> 14 #include <memory>
15 #include <utility> 15 #include <utility>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/location.h" 19 #include "base/location.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "mojo/edk/embedder/platform_channel_utils.h" 23 #include "mojo/edk/embedder/platform_channel_utils.h"
24 #include "mojo/edk/embedder/platform_handle.h" 24 #include "mojo/edk/platform/platform_handle.h"
25 #include "mojo/edk/embedder/scoped_platform_handle.h" 25 #include "mojo/edk/platform/scoped_platform_handle.h"
26 #include "mojo/edk/system/transport_data.h" 26 #include "mojo/edk/system/transport_data.h"
27 #include "mojo/edk/util/make_unique.h" 27 #include "mojo/edk/util/make_unique.h"
28 #include "mojo/public/cpp/system/macros.h" 28 #include "mojo/public/cpp/system/macros.h"
29 29
30 using mojo::embedder::ScopedPlatformHandle; 30 using mojo::platform::PlatformHandle;
31 using mojo::platform::ScopedPlatformHandle;
31 using mojo::util::MakeUnique; 32 using mojo::util::MakeUnique;
32 using mojo::util::MutexLocker; 33 using mojo::util::MutexLocker;
33 34
34 namespace mojo { 35 namespace mojo {
35 namespace system { 36 namespace system {
36 37
37 namespace { 38 namespace {
38 39
39 class RawChannelPosix final : public RawChannel, 40 class RawChannelPosix final : public RawChannel,
40 public base::MessageLoopForIO::Watcher { 41 public base::MessageLoopForIO::Watcher {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 RawChannel::IOResult RawChannelPosix::WriteNoLock( 222 RawChannel::IOResult RawChannelPosix::WriteNoLock(
222 size_t* platform_handles_written, 223 size_t* platform_handles_written,
223 size_t* bytes_written) { 224 size_t* bytes_written) {
224 write_mutex().AssertHeld(); 225 write_mutex().AssertHeld();
225 226
226 DCHECK(!pending_write_); 227 DCHECK(!pending_write_);
227 228
228 size_t num_platform_handles = 0; 229 size_t num_platform_handles = 0;
229 ssize_t write_result; 230 ssize_t write_result;
230 if (write_buffer_no_lock()->HavePlatformHandlesToSend()) { 231 if (write_buffer_no_lock()->HavePlatformHandlesToSend()) {
231 embedder::PlatformHandle* platform_handles; 232 PlatformHandle* platform_handles;
232 void* serialization_data; // Actually unused. 233 void* serialization_data; // Actually unused.
233 write_buffer_no_lock()->GetPlatformHandlesToSend( 234 write_buffer_no_lock()->GetPlatformHandlesToSend(
234 &num_platform_handles, &platform_handles, &serialization_data); 235 &num_platform_handles, &platform_handles, &serialization_data);
235 DCHECK_GT(num_platform_handles, 0u); 236 DCHECK_GT(num_platform_handles, 0u);
236 DCHECK_LE(num_platform_handles, embedder::kPlatformChannelMaxNumHandles); 237 DCHECK_LE(num_platform_handles, embedder::kPlatformChannelMaxNumHandles);
237 DCHECK(platform_handles); 238 DCHECK(platform_handles);
238 239
239 // TODO(vtl): Reduce code duplication. (This is duplicated from below.) 240 // TODO(vtl): Reduce code duplication. (This is duplicated from below.)
240 std::vector<WriteBuffer::Buffer> buffers; 241 std::vector<WriteBuffer::Buffer> buffers;
241 write_buffer_no_lock()->GetBuffers(&buffers); 242 write_buffer_no_lock()->GetBuffers(&buffers);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // ----------------------------------------------------------------------------- 475 // -----------------------------------------------------------------------------
475 476
476 // Static factory method declared in raw_channel.h. 477 // Static factory method declared in raw_channel.h.
477 // static 478 // static
478 std::unique_ptr<RawChannel> RawChannel::Create(ScopedPlatformHandle handle) { 479 std::unique_ptr<RawChannel> RawChannel::Create(ScopedPlatformHandle handle) {
479 return MakeUnique<RawChannelPosix>(handle.Pass()); 480 return MakeUnique<RawChannelPosix>(handle.Pass());
480 } 481 }
481 482
482 } // namespace system 483 } // namespace system
483 } // namespace mojo 484 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/raw_channel.cc ('k') | mojo/edk/system/raw_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698