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

Side by Side Diff: ppapi/proxy/nacl_message_scanner.cc

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 years, 8 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 | « ppapi/proxy/nacl_message_scanner.h ('k') | ppapi/proxy/nacl_message_scanner_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 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 "ppapi/proxy/nacl_message_scanner.h" 5 #include "ppapi/proxy/nacl_message_scanner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 27 matching lines...) Expand all
38 38
39 // Vector to hold handles found in the message. 39 // Vector to hold handles found in the message.
40 Handles handles; 40 Handles handles;
41 // Current handle index in the rewritten message. During the scan, it will be 41 // Current handle index in the rewritten message. During the scan, it will be
42 // be less than or equal to handles.size(). After the scan it should be equal. 42 // be less than or equal to handles.size(). After the scan it should be equal.
43 int handle_index; 43 int handle_index;
44 // The rewritten message. This may be NULL, so all ScanParam overloads should 44 // The rewritten message. This may be NULL, so all ScanParam overloads should
45 // check for NULL before writing to it. In some cases, a ScanParam overload 45 // check for NULL before writing to it. In some cases, a ScanParam overload
46 // may set this to NULL when it can determine that there are no parameters 46 // may set this to NULL when it can determine that there are no parameters
47 // that need conversion. (See the ResourceMessageReplyParams overload.) 47 // that need conversion. (See the ResourceMessageReplyParams overload.)
48 scoped_ptr<IPC::Message> new_msg; 48 std::unique_ptr<IPC::Message> new_msg;
49 // Resource id for resource messages. Save this when scanning resource replies 49 // Resource id for resource messages. Save this when scanning resource replies
50 // so when we audit the nested message, we know which resource it is for. 50 // so when we audit the nested message, we know which resource it is for.
51 PP_Resource pp_resource; 51 PP_Resource pp_resource;
52 // Callback to receive the nested message in a resource message or reply. 52 // Callback to receive the nested message in a resource message or reply.
53 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> 53 base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)>
54 nested_msg_callback; 54 nested_msg_callback;
55 }; 55 };
56 56
57 void WriteHandle(int handle_index, 57 void WriteHandle(int handle_index,
58 const SerializedHandle& handle, 58 const SerializedHandle& handle,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // message body, rather than passed in a separate FileDescriptorSet. Therefore, 331 // message body, rather than passed in a separate FileDescriptorSet. Therefore,
332 // on Windows, any message containing handles must be rewritten in the POSIX 332 // on Windows, any message containing handles must be rewritten in the POSIX
333 // format before we can send it to the NaCl plugin. 333 // format before we can send it to the NaCl plugin.
334 // On Mac, base::SharedMemoryHandle has a different serialization than 334 // On Mac, base::SharedMemoryHandle has a different serialization than
335 // base::FileDescriptor (which base::SharedMemoryHandle is typedef-ed to in 335 // base::FileDescriptor (which base::SharedMemoryHandle is typedef-ed to in
336 // OS_NACL). 336 // OS_NACL).
337 bool NaClMessageScanner::ScanMessage( 337 bool NaClMessageScanner::ScanMessage(
338 const IPC::Message& msg, 338 const IPC::Message& msg,
339 uint32_t type, 339 uint32_t type,
340 std::vector<SerializedHandle>* handles, 340 std::vector<SerializedHandle>* handles,
341 scoped_ptr<IPC::Message>* new_msg_ptr) { 341 std::unique_ptr<IPC::Message>* new_msg_ptr) {
342 DCHECK(handles); 342 DCHECK(handles);
343 DCHECK(handles->empty()); 343 DCHECK(handles->empty());
344 DCHECK(new_msg_ptr); 344 DCHECK(new_msg_ptr);
345 DCHECK(!new_msg_ptr->get()); 345 DCHECK(!new_msg_ptr->get());
346 346
347 bool rewrite_msg = 347 bool rewrite_msg =
348 #if defined(OS_WIN) || defined(OS_MACOSX) 348 #if defined(OS_WIN) || defined(OS_MACOSX)
349 true; 349 true;
350 #else 350 #else
351 false; 351 false;
(...skipping 30 matching lines...) Expand all
382 // we ever add new param types that also require rewriting. 382 // we ever add new param types that also require rewriting.
383 if (!results.handles.empty()) { 383 if (!results.handles.empty()) {
384 handles->swap(results.handles); 384 handles->swap(results.handles);
385 *new_msg_ptr = std::move(results.new_msg); 385 *new_msg_ptr = std::move(results.new_msg);
386 } 386 }
387 return true; 387 return true;
388 } 388 }
389 389
390 void NaClMessageScanner::ScanUntrustedMessage( 390 void NaClMessageScanner::ScanUntrustedMessage(
391 const IPC::Message& untrusted_msg, 391 const IPC::Message& untrusted_msg,
392 scoped_ptr<IPC::Message>* new_msg_ptr) { 392 std::unique_ptr<IPC::Message>* new_msg_ptr) {
393 // Audit FileIO and FileSystem messages to ensure that the plugin doesn't 393 // Audit FileIO and FileSystem messages to ensure that the plugin doesn't
394 // exceed its file quota. If we find the message is malformed, just pass it 394 // exceed its file quota. If we find the message is malformed, just pass it
395 // through - we only care about well formed messages to the host. 395 // through - we only care about well formed messages to the host.
396 if (untrusted_msg.type() == PpapiHostMsg_ResourceCall::ID) { 396 if (untrusted_msg.type() == PpapiHostMsg_ResourceCall::ID) {
397 ResourceMessageCallParams params; 397 ResourceMessageCallParams params;
398 IPC::Message nested_msg; 398 IPC::Message nested_msg;
399 if (!UnpackMessage<PpapiHostMsg_ResourceCall>( 399 if (!UnpackMessage<PpapiHostMsg_ResourceCall>(
400 untrusted_msg, &params, &nested_msg)) 400 untrusted_msg, &params, &nested_msg))
401 return; 401 return;
402 402
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 fio_it->second->SetMaxWrittenOffset(offset_it->second); 559 fio_it->second->SetMaxWrittenOffset(offset_it->second);
560 } 560 }
561 } 561 }
562 break; 562 break;
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 } // namespace proxy 567 } // namespace proxy
568 } // namespace ppapi 568 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/nacl_message_scanner.h ('k') | ppapi/proxy/nacl_message_scanner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698