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

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

Issue 2008953003: [mojo-edk] Explicitly serialise HANDLEs into messages instead of PlatformHandles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove handles accessor Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/channel.h" 5 #include "mojo/edk/system/channel.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 } 115 }
116 116
117 bool GetReadPlatformHandles( 117 bool GetReadPlatformHandles(
118 size_t num_handles, 118 size_t num_handles,
119 const void* extra_header, 119 const void* extra_header,
120 size_t extra_header_size, 120 size_t extra_header_size,
121 ScopedPlatformHandleVectorPtr* handles) override { 121 ScopedPlatformHandleVectorPtr* handles) override {
122 if (num_handles > std::numeric_limits<uint16_t>::max()) 122 if (num_handles > std::numeric_limits<uint16_t>::max())
123 return false; 123 return false;
124 size_t handles_size = sizeof(PlatformHandle) * num_handles; 124 size_t handles_size = sizeof(HANDLE) * num_handles;
125 if (handles_size > extra_header_size) 125 if (handles_size > extra_header_size)
126 return false; 126 return false;
127 DCHECK(extra_header); 127 DCHECK(extra_header);
128 handles->reset(new PlatformHandleVector(num_handles)); 128 handles->reset(new PlatformHandleVector(num_handles));
129 memcpy((*handles)->data(), extra_header, handles_size); 129 const HANDLE* extra_header_handles =
130 reinterpret_cast<const HANDLE*>(extra_header);
131 for (size_t i = 0; i < num_handles; i++)
132 (*handles)->at(i).handle = extra_header_handles[i];
130 return true; 133 return true;
131 } 134 }
132 135
133 private: 136 private:
134 // May run on any thread. 137 // May run on any thread.
135 ~ChannelWin() override {} 138 ~ChannelWin() override {}
136 139
137 void StartOnIOThread() { 140 void StartOnIOThread() {
138 base::MessageLoop::current()->AddDestructionObserver(this); 141 base::MessageLoop::current()->AddDestructionObserver(this);
139 base::MessageLoopForIO::current()->RegisterIOHandler( 142 base::MessageLoopForIO::current()->RegisterIOHandler(
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // static 299 // static
297 scoped_refptr<Channel> Channel::Create( 300 scoped_refptr<Channel> Channel::Create(
298 Delegate* delegate, 301 Delegate* delegate,
299 ScopedPlatformHandle platform_handle, 302 ScopedPlatformHandle platform_handle,
300 scoped_refptr<base::TaskRunner> io_task_runner) { 303 scoped_refptr<base::TaskRunner> io_task_runner) {
301 return new ChannelWin(delegate, std::move(platform_handle), io_task_runner); 304 return new ChannelWin(delegate, std::move(platform_handle), io_task_runner);
302 } 305 }
303 306
304 } // namespace edk 307 } // namespace edk
305 } // namespace mojo 308 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698