Stop using ByteSize (deprecated) to get the size of a proto message.

The method ByteSize has been deprecated [1], this CL switches to
ByteSizeLong.

[1] - https://cs.chromium.org/chromium/src/third_party/protobuf/src/google/protobuf/message_lite.h?l=252&rcl=ac47edd22c481fcfe119769d6b7abf365abea8fa

Bug: None
Change-Id: I1ba622df52f47719a5beda6d230cb603a0163d43
Reviewed-on: https://webrtc-review.googlesource.com/27021
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20952}
diff --git a/logging/rtc_event_log/rtc_event_log2stats.cc b/logging/rtc_event_log/rtc_event_log2stats.cc
index 10fb53c..7373736 100644
--- a/logging/rtc_event_log/rtc_event_log2stats.cc
+++ b/logging/rtc_event_log/rtc_event_log2stats.cc
@@ -214,7 +214,7 @@
   size_t malformed_event_size = 0;
   size_t accumulated_event_size = 0;
   for (const webrtc::rtclog::Event& event : events) {
-    size_t serialized_size = event.ByteSize();
+    size_t serialized_size = event.ByteSizeLong();
     // When the event is written on the disk, it is part of an EventStream
     // object. The event stream will prepend a 1 byte field number/wire type,
     // and a varint encoding (base 128) of the event length.
diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
index 97de177..818362e 100644
--- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
+++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
@@ -12,6 +12,7 @@
 
 #include "rtc_base/checks.h"
 #include "rtc_base/ignore_wundef.h"
+#include "rtc_base/numerics/safe_conversions.h"
 #include "rtc_base/protobuf_utils.h"
 
 #if WEBRTC_ENABLE_PROTOBUF
@@ -37,7 +38,7 @@
   RTC_CHECK(dump_file->is_open());
   ProtoString dump_data;
   event.SerializeToString(&dump_data);
-  int32_t size = event.ByteSize();
+  int32_t size = rtc::checked_cast<int32_t>(event.ByteSizeLong());
   dump_file->Write(&size, sizeof(size));
   dump_file->Write(dump_data.data(), dump_data.length());
 }
diff --git a/modules/audio_processing/aec_dump/write_to_file_task.cc b/modules/audio_processing/aec_dump/write_to_file_task.cc
index 5fdfd4e..8dddd47 100644
--- a/modules/audio_processing/aec_dump/write_to_file_task.cc
+++ b/modules/audio_processing/aec_dump/write_to_file_task.cc
@@ -46,7 +46,7 @@
   ProtoString event_string;
   event_.SerializeToString(&event_string);
 
-  const size_t event_byte_size = event_.ByteSize();
+  const size_t event_byte_size = event_.ByteSizeLong();
 
   if (!IsRoomForNextEvent(event_byte_size)) {
     debug_file_->CloseFile();
diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc
index 4da0621..5984ed7 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -33,6 +33,7 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/gtest_prod_util.h"
 #include "rtc_base/ignore_wundef.h"
+#include "rtc_base/numerics/safe_conversions.h"
 #include "rtc_base/numerics/safe_minmax.h"
 #include "rtc_base/protobuf_utils.h"
 #include "rtc_base/refcountedobject.h"
@@ -243,7 +244,7 @@
   FILE* file = fopen(filename.c_str(), "wb");
   ASSERT_TRUE(file != NULL);
 
-  int32_t size = msg.ByteSize();
+  int32_t size = rtc::checked_cast<int32_t>(msg.ByteSizeLong());
   ASSERT_GT(size, 0);
   std::unique_ptr<uint8_t[]> array(new uint8_t[size]);
   ASSERT_TRUE(msg.SerializeToArray(array.get(), size));
diff --git a/rtc_tools/network_tester/test_controller.cc b/rtc_tools/network_tester/test_controller.cc
index ea03c87..a3a8833 100644
--- a/rtc_tools/network_tester/test_controller.cc
+++ b/rtc_tools/network_tester/test_controller.cc
@@ -51,7 +51,7 @@
 void TestController::SendData(const NetworkTesterPacket& packet,
                               rtc::Optional<size_t> data_size) {
   // Can be call from packet_sender or from test_controller thread.
-  size_t packet_size = packet.ByteSize();
+  size_t packet_size = packet.ByteSizeLong();
   send_data_[0] = packet_size;
   packet_size++;
   packet.SerializeToArray(&send_data_[1], std::numeric_limits<char>::max());