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

Side by Side Diff: util/mach/mach_message_server_test.cc

Issue 1405273002: Mach port scopers should use get() instead of type conversion operators (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: More is_valid() 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 | « util/mach/mach_extensions_test.cc ('k') | util/mach/mach_message_test.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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 break; 460 break;
461 case Options::kReplyPortNull: 461 case Options::kReplyPortNull:
462 request.header.msgh_local_port = MACH_PORT_NULL; 462 request.header.msgh_local_port = MACH_PORT_NULL;
463 break; 463 break;
464 case Options::kReplyPortDead: { 464 case Options::kReplyPortDead: {
465 // Use a newly-allocated receive right that will be destroyed when this 465 // Use a newly-allocated receive right that will be destroyed when this
466 // method returns. A send right will be made from this receive right and 466 // method returns. A send right will be made from this receive right and
467 // carried in the request message to the server. By the time the server 467 // carried in the request message to the server. By the time the server
468 // looks at the right, it will have become a dead name. 468 // looks at the right, it will have become a dead name.
469 local_receive_port_owner.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 469 local_receive_port_owner.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE));
470 ASSERT_NE(kMachPortNull, local_receive_port_owner); 470 ASSERT_TRUE(local_receive_port_owner.is_valid());
471 request.header.msgh_local_port = local_receive_port_owner; 471 request.header.msgh_local_port = local_receive_port_owner.get();
472 break; 472 break;
473 } 473 }
474 } 474 }
475 request.header.msgh_id = kRequestMessageID; 475 request.header.msgh_id = kRequestMessageID;
476 if (options_.client_send_complex) { 476 if (options_.client_send_complex) {
477 // Allocate a new receive right in this process and make a send right that 477 // Allocate a new receive right in this process and make a send right that
478 // will appear in the parent process. This is used to test that the server 478 // will appear in the parent process. This is used to test that the server
479 // properly handles ownership of resources received in complex messages. 479 // properly handles ownership of resources received in complex messages.
480 request.body.msgh_descriptor_count = 1; 480 request.body.msgh_descriptor_count = 1;
481 child_complex_message_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); 481 child_complex_message_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE));
482 ASSERT_NE(kMachPortNull, child_complex_message_port_); 482 ASSERT_TRUE(child_complex_message_port_.is_valid());
483 request.port_descriptor.name = child_complex_message_port_; 483 request.port_descriptor.name = child_complex_message_port_.get();
484 request.port_descriptor.disposition = MACH_MSG_TYPE_MAKE_SEND; 484 request.port_descriptor.disposition = MACH_MSG_TYPE_MAKE_SEND;
485 request.port_descriptor.type = MACH_MSG_PORT_DESCRIPTOR; 485 request.port_descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
486 } else { 486 } else {
487 request.body.msgh_descriptor_count = 0; 487 request.body.msgh_descriptor_count = 0;
488 request.port_descriptor.name = MACH_PORT_NULL; 488 request.port_descriptor.name = MACH_PORT_NULL;
489 request.port_descriptor.disposition = 0; 489 request.port_descriptor.disposition = 0;
490 request.port_descriptor.type = 0; 490 request.port_descriptor.type = 0;
491 } 491 }
492 request.ndr = NDR_record; 492 request.ndr = NDR_record;
493 request.number = requests_++; 493 request.number = requests_++;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 options.expect_server_transaction_count = 0; 845 options.expect_server_transaction_count = 0;
846 options.client_send_large = true; 846 options.client_send_large = true;
847 options.client_expect_reply = false; 847 options.client_expect_reply = false;
848 TestMachMessageServer test_mach_message_server(options); 848 TestMachMessageServer test_mach_message_server(options);
849 test_mach_message_server.Test(); 849 test_mach_message_server.Test();
850 } 850 }
851 851
852 } // namespace 852 } // namespace
853 } // namespace test 853 } // namespace test
854 } // namespace crashpad 854 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/mach_extensions_test.cc ('k') | util/mach/mach_message_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698