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

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

Issue 1350953003: Use std::is_same to check for identical types. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ipc_support.h" 5 #include "mojo/edk/system/ipc_support.h"
6 6
7 #include <type_traits>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "mojo/edk/embedder/master_process_delegate.h" 10 #include "mojo/edk/embedder/master_process_delegate.h"
9 #include "mojo/edk/embedder/slave_process_delegate.h" 11 #include "mojo/edk/embedder/slave_process_delegate.h"
10 #include "mojo/edk/system/channel_manager.h" 12 #include "mojo/edk/system/channel_manager.h"
11 #include "mojo/edk/system/master_connection_manager.h" 13 #include "mojo/edk/system/master_connection_manager.h"
12 #include "mojo/edk/system/message_pipe_dispatcher.h" 14 #include "mojo/edk/system/message_pipe_dispatcher.h"
13 #include "mojo/edk/system/slave_connection_manager.h" 15 #include "mojo/edk/system/slave_connection_manager.h"
14 16
15 namespace mojo { 17 namespace mojo {
16 namespace system { 18 namespace system {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToSlave( 91 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToSlave(
90 const ConnectionIdentifier& connection_id, 92 const ConnectionIdentifier& connection_id,
91 embedder::SlaveInfo slave_info, 93 embedder::SlaveInfo slave_info,
92 embedder::ScopedPlatformHandle platform_handle, 94 embedder::ScopedPlatformHandle platform_handle,
93 const base::Closure& callback, 95 const base::Closure& callback,
94 scoped_refptr<base::TaskRunner> callback_thread_task_runner, 96 scoped_refptr<base::TaskRunner> callback_thread_task_runner,
95 ChannelId* channel_id) { 97 ChannelId* channel_id) {
96 DCHECK(channel_id); 98 DCHECK(channel_id);
97 99
98 // We rely on |ChannelId| and |ProcessIdentifier| being identical types. 100 // We rely on |ChannelId| and |ProcessIdentifier| being identical types.
99 // TODO(vtl): Use std::is_same instead when we are allowed to (C++11 library). 101 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
100 static_assert(sizeof(ChannelId) == sizeof(ProcessIdentifier),
101 "ChannelId and ProcessIdentifier types don't match"); 102 "ChannelId and ProcessIdentifier types don't match");
102 103
103 embedder::ScopedPlatformHandle platform_connection_handle = 104 embedder::ScopedPlatformHandle platform_connection_handle =
104 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(), 105 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(),
105 channel_id); 106 channel_id);
106 return channel_manager()->CreateChannel( 107 return channel_manager()->CreateChannel(
107 *channel_id, platform_connection_handle.Pass(), callback, 108 *channel_id, platform_connection_handle.Pass(), callback,
108 callback_thread_task_runner); 109 callback_thread_task_runner);
109 } 110 }
110 111
111 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToMaster( 112 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToMaster(
112 const ConnectionIdentifier& connection_id, 113 const ConnectionIdentifier& connection_id,
113 const base::Closure& callback, 114 const base::Closure& callback,
114 scoped_refptr<base::TaskRunner> callback_thread_task_runner, 115 scoped_refptr<base::TaskRunner> callback_thread_task_runner,
115 ChannelId* channel_id) { 116 ChannelId* channel_id) {
116 DCHECK(channel_id); 117 DCHECK(channel_id);
117 118
118 // TODO(vtl): Use std::is_same instead when we are allowed to (C++11 library). 119 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
119 static_assert(sizeof(ChannelId) == sizeof(ProcessIdentifier),
120 "ChannelId and ProcessIdentifier types don't match"); 120 "ChannelId and ProcessIdentifier types don't match");
121 embedder::ScopedPlatformHandle platform_connection_handle = 121 embedder::ScopedPlatformHandle platform_connection_handle =
122 ConnectToMasterInternal(connection_id); 122 ConnectToMasterInternal(connection_id);
123 *channel_id = kMasterProcessIdentifier; 123 *channel_id = kMasterProcessIdentifier;
124 return channel_manager()->CreateChannel( 124 return channel_manager()->CreateChannel(
125 *channel_id, platform_connection_handle.Pass(), callback, 125 *channel_id, platform_connection_handle.Pass(), callback,
126 callback_thread_task_runner); 126 callback_thread_task_runner);
127 } 127 }
128 128
129 embedder::ScopedPlatformHandle IPCSupport::ConnectToSlaveInternal( 129 embedder::ScopedPlatformHandle IPCSupport::ConnectToSlaveInternal(
(...skipping 30 matching lines...) Expand all
160 CHECK_EQ(connection_manager()->Connect(connection_id, &peer_id, &is_first, 160 CHECK_EQ(connection_manager()->Connect(connection_id, &peer_id, &is_first,
161 &platform_connection_handle), 161 &platform_connection_handle),
162 ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION); 162 ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION);
163 DCHECK_EQ(peer_id, system::kMasterProcessIdentifier); 163 DCHECK_EQ(peer_id, system::kMasterProcessIdentifier);
164 DCHECK(platform_connection_handle.is_valid()); 164 DCHECK(platform_connection_handle.is_valid());
165 return platform_connection_handle; 165 return platform_connection_handle;
166 } 166 }
167 167
168 } // namespace system 168 } // namespace system
169 } // namespace mojo 169 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698