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

Side by Side Diff: mojo/public/cpp/bindings/lib/message.cc

Issue 2691393002: Fix auto raw pointer deduction on linux (Closed)
Patch Set: rebase Created 3 years, 10 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 | « media/remoting/proto_utils.cc ('k') | mojo/public/cpp/bindings/lib/message_header_validator.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/public/cpp/bindings/message.h" 5 #include "mojo/public/cpp/bindings/message.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 payload_end = reinterpret_cast<uintptr_t>(data() + data_num_bytes()); 99 payload_end = reinterpret_cast<uintptr_t>(data() + data_num_bytes());
100 DCHECK_GE(payload_end, payload); 100 DCHECK_GE(payload_end, payload);
101 num_bytes = payload_end - payload; 101 num_bytes = payload_end - payload;
102 } 102 }
103 } 103 }
104 DCHECK_LE(num_bytes, std::numeric_limits<uint32_t>::max()); 104 DCHECK_LE(num_bytes, std::numeric_limits<uint32_t>::max());
105 return static_cast<uint32_t>(num_bytes); 105 return static_cast<uint32_t>(num_bytes);
106 } 106 }
107 107
108 uint32_t Message::payload_num_interface_ids() const { 108 uint32_t Message::payload_num_interface_ids() const {
109 auto array_pointer = 109 auto* array_pointer =
110 version() < 2 ? nullptr : header_v2()->payload_interface_ids.Get(); 110 version() < 2 ? nullptr : header_v2()->payload_interface_ids.Get();
111 return array_pointer ? static_cast<uint32_t>(array_pointer->size()) : 0; 111 return array_pointer ? static_cast<uint32_t>(array_pointer->size()) : 0;
112 } 112 }
113 113
114 const uint32_t* Message::payload_interface_ids() const { 114 const uint32_t* Message::payload_interface_ids() const {
115 auto array_pointer = 115 auto* array_pointer =
116 version() < 2 ? nullptr : header_v2()->payload_interface_ids.Get(); 116 version() < 2 ? nullptr : header_v2()->payload_interface_ids.Get();
117 return array_pointer ? array_pointer->storage() : nullptr; 117 return array_pointer ? array_pointer->storage() : nullptr;
118 } 118 }
119 119
120 ScopedMessageHandle Message::TakeMojoMessage() { 120 ScopedMessageHandle Message::TakeMojoMessage() {
121 // If there are associated endpoints transferred, 121 // If there are associated endpoints transferred,
122 // SerializeAssociatedEndpointHandles() must be called before this method. 122 // SerializeAssociatedEndpointHandles() must be called before this method.
123 DCHECK(associated_endpoint_handles_.empty()); 123 DCHECK(associated_endpoint_handles_.empty());
124 124
125 if (handles_.empty()) // Fast path for the common case: No handles. 125 if (handles_.empty()) // Fast path for the common case: No handles.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 void Message::SerializeAssociatedEndpointHandles( 168 void Message::SerializeAssociatedEndpointHandles(
169 AssociatedGroupController* group_controller) { 169 AssociatedGroupController* group_controller) {
170 if (associated_endpoint_handles_.empty()) 170 if (associated_endpoint_handles_.empty())
171 return; 171 return;
172 172
173 DCHECK_GE(version(), 2u); 173 DCHECK_GE(version(), 2u);
174 DCHECK(header_v2()->payload_interface_ids.is_null()); 174 DCHECK(header_v2()->payload_interface_ids.is_null());
175 175
176 size_t size = associated_endpoint_handles_.size(); 176 size_t size = associated_endpoint_handles_.size();
177 auto data = internal::Array_Data<uint32_t>::New(size, buffer()); 177 auto* data = internal::Array_Data<uint32_t>::New(size, buffer());
178 header_v2()->payload_interface_ids.Set(data); 178 header_v2()->payload_interface_ids.Set(data);
179 179
180 for (size_t i = 0; i < size; ++i) { 180 for (size_t i = 0; i < size; ++i) {
181 ScopedInterfaceEndpointHandle& handle = associated_endpoint_handles_[i]; 181 ScopedInterfaceEndpointHandle& handle = associated_endpoint_handles_[i];
182 182
183 DCHECK(handle.pending_association()); 183 DCHECK(handle.pending_association());
184 data->storage()[i] = 184 data->storage()[i] =
185 group_controller->AssociateInterface(std::move(handle)); 185 group_controller->AssociateInterface(std::move(handle));
186 } 186 }
187 associated_endpoint_handles_.clear(); 187 associated_endpoint_handles_.clear();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // static 323 // static
324 void SyncMessageResponseSetup::SetCurrentSyncResponseMessage(Message* message) { 324 void SyncMessageResponseSetup::SetCurrentSyncResponseMessage(Message* message) {
325 SyncMessageResponseContext* context = SyncMessageResponseContext::current(); 325 SyncMessageResponseContext* context = SyncMessageResponseContext::current();
326 if (context) 326 if (context)
327 context->response_ = std::move(*message); 327 context->response_ = std::move(*message);
328 } 328 }
329 329
330 } // namespace internal 330 } // namespace internal
331 331
332 } // namespace mojo 332 } // namespace mojo
OLDNEW
« no previous file with comments | « media/remoting/proto_utils.cc ('k') | mojo/public/cpp/bindings/lib/message_header_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698