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

Side by Side Diff: dbus/message.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "dbus/message.h" 5 #include "dbus/message.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // not be a big issue. 529 // not be a big issue.
530 void MessageWriter::OpenArray(const std::string& signature, 530 void MessageWriter::OpenArray(const std::string& signature,
531 MessageWriter* writer) { 531 MessageWriter* writer) {
532 DCHECK(!container_is_open_); 532 DCHECK(!container_is_open_);
533 533
534 const bool success = dbus_message_iter_open_container( 534 const bool success = dbus_message_iter_open_container(
535 &raw_message_iter_, 535 &raw_message_iter_,
536 DBUS_TYPE_ARRAY, 536 DBUS_TYPE_ARRAY,
537 signature.c_str(), 537 signature.c_str(),
538 &writer->raw_message_iter_); 538 &writer->raw_message_iter_);
539 CHECK(success) << "Unable to allocate memory"; 539 // Unable to allocate memory
540 CHECK(success);
540 container_is_open_ = true; 541 container_is_open_ = true;
541 } 542 }
542 543
543 void MessageWriter::OpenVariant(const std::string& signature, 544 void MessageWriter::OpenVariant(const std::string& signature,
544 MessageWriter* writer) { 545 MessageWriter* writer) {
545 DCHECK(!container_is_open_); 546 DCHECK(!container_is_open_);
546 547
547 const bool success = dbus_message_iter_open_container( 548 const bool success = dbus_message_iter_open_container(
548 &raw_message_iter_, 549 &raw_message_iter_,
549 DBUS_TYPE_VARIANT, 550 DBUS_TYPE_VARIANT,
550 signature.c_str(), 551 signature.c_str(),
551 &writer->raw_message_iter_); 552 &writer->raw_message_iter_);
552 CHECK(success) << "Unable to allocate memory"; 553 // Unable to allocate memory
554 CHECK(success);
553 container_is_open_ = true; 555 container_is_open_ = true;
554 } 556 }
555 557
556 void MessageWriter::OpenStruct(MessageWriter* writer) { 558 void MessageWriter::OpenStruct(MessageWriter* writer) {
557 DCHECK(!container_is_open_); 559 DCHECK(!container_is_open_);
558 560
559 const bool success = dbus_message_iter_open_container( 561 const bool success = dbus_message_iter_open_container(
560 &raw_message_iter_, 562 &raw_message_iter_,
561 DBUS_TYPE_STRUCT, 563 DBUS_TYPE_STRUCT,
562 NULL, // Signature should be NULL. 564 NULL, // Signature should be NULL.
563 &writer->raw_message_iter_); 565 &writer->raw_message_iter_);
564 CHECK(success) << "Unable to allocate memory"; 566 // Unable to allocate memory
567 CHECK(success);
565 container_is_open_ = true; 568 container_is_open_ = true;
566 } 569 }
567 570
568 void MessageWriter::OpenDictEntry(MessageWriter* writer) { 571 void MessageWriter::OpenDictEntry(MessageWriter* writer) {
569 DCHECK(!container_is_open_); 572 DCHECK(!container_is_open_);
570 573
571 const bool success = dbus_message_iter_open_container( 574 const bool success = dbus_message_iter_open_container(
572 &raw_message_iter_, 575 &raw_message_iter_,
573 DBUS_TYPE_DICT_ENTRY, 576 DBUS_TYPE_DICT_ENTRY,
574 NULL, // Signature should be NULL. 577 NULL, // Signature should be NULL.
575 &writer->raw_message_iter_); 578 &writer->raw_message_iter_);
576 CHECK(success) << "Unable to allocate memory"; 579 // Unable to allocate memory
580 CHECK(success);
577 container_is_open_ = true; 581 container_is_open_ = true;
578 } 582 }
579 583
580 void MessageWriter::CloseContainer(MessageWriter* writer) { 584 void MessageWriter::CloseContainer(MessageWriter* writer) {
581 DCHECK(container_is_open_); 585 DCHECK(container_is_open_);
582 586
583 const bool success = dbus_message_iter_close_container( 587 const bool success = dbus_message_iter_close_container(
584 &raw_message_iter_, &writer->raw_message_iter_); 588 &raw_message_iter_, &writer->raw_message_iter_);
585 CHECK(success) << "Unable to allocate memory"; 589 // Unable to allocate memory
590 CHECK(success);
586 container_is_open_ = false; 591 container_is_open_ = false;
587 } 592 }
588 593
589 void MessageWriter::AppendArrayOfBytes(const uint8_t* values, size_t length) { 594 void MessageWriter::AppendArrayOfBytes(const uint8_t* values, size_t length) {
590 DCHECK(!container_is_open_); 595 DCHECK(!container_is_open_);
591 MessageWriter array_writer(message_); 596 MessageWriter array_writer(message_);
592 OpenArray("y", &array_writer); 597 OpenArray("y", &array_writer);
593 const bool success = dbus_message_iter_append_fixed_array( 598 const bool success = dbus_message_iter_append_fixed_array(
594 &(array_writer.raw_message_iter_), 599 &(array_writer.raw_message_iter_),
595 DBUS_TYPE_BYTE, 600 DBUS_TYPE_BYTE,
596 &values, 601 &values,
597 static_cast<int>(length)); 602 static_cast<int>(length));
598 CHECK(success) << "Unable to allocate memory"; 603 // Unable to allocate memory
604 CHECK(success);
599 CloseContainer(&array_writer); 605 CloseContainer(&array_writer);
600 } 606 }
601 607
602 void MessageWriter::AppendArrayOfDoubles(const double* values, size_t length) { 608 void MessageWriter::AppendArrayOfDoubles(const double* values, size_t length) {
603 DCHECK(!container_is_open_); 609 DCHECK(!container_is_open_);
604 MessageWriter array_writer(message_); 610 MessageWriter array_writer(message_);
605 OpenArray("d", &array_writer); 611 OpenArray("d", &array_writer);
606 const bool success = dbus_message_iter_append_fixed_array( 612 const bool success = dbus_message_iter_append_fixed_array(
607 &(array_writer.raw_message_iter_), 613 &(array_writer.raw_message_iter_),
608 DBUS_TYPE_DOUBLE, 614 DBUS_TYPE_DOUBLE,
609 &values, 615 &values,
610 static_cast<int>(length)); 616 static_cast<int>(length));
611 CHECK(success) << "Unable to allocate memory"; 617 // Unable to allocate memory
618 CHECK(success);
612 CloseContainer(&array_writer); 619 CloseContainer(&array_writer);
613 } 620 }
614 621
615 void MessageWriter::AppendArrayOfStrings( 622 void MessageWriter::AppendArrayOfStrings(
616 const std::vector<std::string>& strings) { 623 const std::vector<std::string>& strings) {
617 DCHECK(!container_is_open_); 624 DCHECK(!container_is_open_);
618 MessageWriter array_writer(message_); 625 MessageWriter array_writer(message_);
619 OpenArray("s", &array_writer); 626 OpenArray("s", &array_writer);
620 for (size_t i = 0; i < strings.size(); ++i) { 627 for (size_t i = 0; i < strings.size(); ++i) {
621 array_writer.AppendString(strings[i]); 628 array_writer.AppendString(strings[i]);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } 702 }
696 703
697 void MessageWriter::AppendBasic(int dbus_type, const void* value) { 704 void MessageWriter::AppendBasic(int dbus_type, const void* value) {
698 DCHECK(!container_is_open_); 705 DCHECK(!container_is_open_);
699 706
700 const bool success = dbus_message_iter_append_basic( 707 const bool success = dbus_message_iter_append_basic(
701 &raw_message_iter_, dbus_type, value); 708 &raw_message_iter_, dbus_type, value);
702 // dbus_message_iter_append_basic() fails only when there is not enough 709 // dbus_message_iter_append_basic() fails only when there is not enough
703 // memory. We don't return this error as there is nothing we can do when 710 // memory. We don't return this error as there is nothing we can do when
704 // it fails to allocate memory for a byte etc. 711 // it fails to allocate memory for a byte etc.
705 CHECK(success) << "Unable to allocate memory"; 712 // Unable to allocate memory
713 CHECK(success);
706 } 714 }
707 715
708 void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) { 716 void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) {
709 const std::string signature(1u, // length 717 const std::string signature(1u, // length
710 base::checked_cast<char>(dbus_type)); 718 base::checked_cast<char>(dbus_type));
711 MessageWriter variant_writer(message_); 719 MessageWriter variant_writer(message_);
712 OpenVariant(signature, &variant_writer); 720 OpenVariant(signature, &variant_writer);
713 variant_writer.AppendBasic(dbus_type, value); 721 variant_writer.AppendBasic(dbus_type, value);
714 CloseContainer(&variant_writer); 722 CloseContainer(&variant_writer);
715 } 723 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 int fd = -1; 1024 int fd = -1;
1017 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); 1025 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd);
1018 if (!success) 1026 if (!success)
1019 return false; 1027 return false;
1020 1028
1021 *value = base::ScopedFD(fd); 1029 *value = base::ScopedFD(fd);
1022 return true; 1030 return true;
1023 } 1031 }
1024 1032
1025 } // namespace dbus 1033 } // namespace dbus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698