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

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

Issue 1412283002: Convert mojo::system::Dispatcher to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: no change Created 5 years, 2 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 | « mojo/edk/system/ipc_support.h ('k') | mojo/edk/system/ipc_support_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 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> 7 #include <type_traits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/edk/embedder/master_process_delegate.h" 10 #include "mojo/edk/embedder/master_process_delegate.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 io_thread_task_runner_ = nullptr; 81 io_thread_task_runner_ = nullptr;
82 process_delegate_ = nullptr; 82 process_delegate_ = nullptr;
83 delegate_thread_task_runner_ = nullptr; 83 delegate_thread_task_runner_ = nullptr;
84 process_type_ = embedder::ProcessType::UNINITIALIZED; 84 process_type_ = embedder::ProcessType::UNINITIALIZED;
85 } 85 }
86 86
87 ConnectionIdentifier IPCSupport::GenerateConnectionIdentifier() { 87 ConnectionIdentifier IPCSupport::GenerateConnectionIdentifier() {
88 return connection_manager()->GenerateConnectionIdentifier(); 88 return connection_manager()->GenerateConnectionIdentifier();
89 } 89 }
90 90
91 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToSlave( 91 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToSlave(
92 const ConnectionIdentifier& connection_id, 92 const ConnectionIdentifier& connection_id,
93 embedder::SlaveInfo slave_info, 93 embedder::SlaveInfo slave_info,
94 embedder::ScopedPlatformHandle platform_handle, 94 embedder::ScopedPlatformHandle platform_handle,
95 const base::Closure& callback, 95 const base::Closure& callback,
96 scoped_refptr<base::TaskRunner> callback_thread_task_runner, 96 scoped_refptr<base::TaskRunner> callback_thread_task_runner,
97 ChannelId* channel_id) { 97 ChannelId* channel_id) {
98 DCHECK(channel_id); 98 DCHECK(channel_id);
99 99
100 // We rely on |ChannelId| and |ProcessIdentifier| being identical types. 100 // We rely on |ChannelId| and |ProcessIdentifier| being identical types.
101 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value, 101 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
102 "ChannelId and ProcessIdentifier types don't match"); 102 "ChannelId and ProcessIdentifier types don't match");
103 103
104 embedder::ScopedPlatformHandle platform_connection_handle = 104 embedder::ScopedPlatformHandle platform_connection_handle =
105 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(), 105 ConnectToSlaveInternal(connection_id, slave_info, platform_handle.Pass(),
106 channel_id); 106 channel_id);
107 return channel_manager()->CreateChannel( 107 return channel_manager()->CreateChannel(
108 *channel_id, platform_connection_handle.Pass(), callback, 108 *channel_id, platform_connection_handle.Pass(), callback,
109 callback_thread_task_runner); 109 callback_thread_task_runner);
110 } 110 }
111 111
112 scoped_refptr<system::MessagePipeDispatcher> IPCSupport::ConnectToMaster( 112 RefPtr<MessagePipeDispatcher> IPCSupport::ConnectToMaster(
113 const ConnectionIdentifier& connection_id, 113 const ConnectionIdentifier& connection_id,
114 const base::Closure& callback, 114 const base::Closure& callback,
115 scoped_refptr<base::TaskRunner> callback_thread_task_runner, 115 scoped_refptr<base::TaskRunner> callback_thread_task_runner,
116 ChannelId* channel_id) { 116 ChannelId* channel_id) {
117 DCHECK(channel_id); 117 DCHECK(channel_id);
118 118
119 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value, 119 static_assert(std::is_same<ChannelId, ProcessIdentifier>::value,
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);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 | « mojo/edk/system/ipc_support.h ('k') | mojo/edk/system/ipc_support_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698