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

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

Issue 1753723003: Revert of [mojo-edk] Serialise windows handles into an "extra header" section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/channel_posix.cc ('k') | 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 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 if (write_error) { 114 if (write_error) {
115 // Do not synchronously invoke OnError(). Write() may have been called by 115 // Do not synchronously invoke OnError(). Write() may have been called by
116 // the delegate and we don't want to re-enter it. 116 // the delegate and we don't want to re-enter it.
117 io_task_runner_->PostTask(FROM_HERE, 117 io_task_runner_->PostTask(FROM_HERE,
118 base::Bind(&ChannelWin::OnError, this)); 118 base::Bind(&ChannelWin::OnError, this));
119 } 119 }
120 } 120 }
121 121
122 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( 122 ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
123 size_t num_handles, 123 size_t num_handles,
124 const void* extra_header, 124 void** payload,
125 size_t extra_header_size) override { 125 size_t* payload_size) override {
126 size_t handles_size = sizeof(PlatformHandle) * num_handles; 126 size_t handles_size = sizeof(PlatformHandle) * num_handles;
127 if (handles_size > extra_header_size) 127 if (handles_size > *payload_size)
128 return nullptr; 128 return nullptr;
129 129
130 *payload_size -= handles_size;
130 ScopedPlatformHandleVectorPtr handles( 131 ScopedPlatformHandleVectorPtr handles(
131 new PlatformHandleVector(num_handles)); 132 new PlatformHandleVector(num_handles));
132 memcpy(handles->data(), extra_header, handles_size); 133 memcpy(handles->data(),
134 static_cast<const char*>(*payload) + *payload_size, handles_size);
133 return handles; 135 return handles;
134 } 136 }
135 137
136 private: 138 private:
137 // May run on any thread. 139 // May run on any thread.
138 ~ChannelWin() override { 140 ~ChannelWin() override {
139 // This is intentionally not 0. If another object is constructed on top of 141 // This is intentionally not 0. If another object is constructed on top of
140 // this memory, it is likely to initialise values to 0. Using a non-zero 142 // this memory, it is likely to initialise values to 0. Using a non-zero
141 // value lets us detect the difference between just destroying, and 143 // value lets us detect the difference between just destroying, and
142 // re-allocating the memory. 144 // re-allocating the memory.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // static 319 // static
318 scoped_refptr<Channel> Channel::Create( 320 scoped_refptr<Channel> Channel::Create(
319 Delegate* delegate, 321 Delegate* delegate,
320 ScopedPlatformHandle platform_handle, 322 ScopedPlatformHandle platform_handle,
321 scoped_refptr<base::TaskRunner> io_task_runner) { 323 scoped_refptr<base::TaskRunner> io_task_runner) {
322 return new ChannelWin(delegate, std::move(platform_handle), io_task_runner); 324 return new ChannelWin(delegate, std::move(platform_handle), io_task_runner);
323 } 325 }
324 326
325 } // namespace edk 327 } // namespace edk
326 } // namespace mojo 328 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698