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

Unified Diff: chrome/browser/media/webrtc_rtp_dump_writer.cc

Issue 614893004: Refactor AppendToFile and WriteFileDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/webrtc_rtp_dump_writer.cc
diff --git a/chrome/browser/media/webrtc_rtp_dump_writer.cc b/chrome/browser/media/webrtc_rtp_dump_writer.cc
index 40e56a1489a486fa9ccf3f9e0a8e601b2bf4b209..e397da03cfd8b674691e072703db151724866260 100644
--- a/chrome/browser/media/webrtc_rtp_dump_writer.cc
+++ b/chrome/browser/media/webrtc_rtp_dump_writer.cc
@@ -7,6 +7,7 @@
#include "base/big_endian.h"
#include "base/files/file_util.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/zlib/zlib.h"
@@ -165,10 +166,13 @@ class WebRtcRtpDumpWriter::FileThreadWorker {
int bytes_written = -1;
if (base::PathExists(dump_path_)) {
- bytes_written = base::AppendToFile(
- dump_path_,
- reinterpret_cast<const char*>(&compressed_buffer[0]),
- compressed_buffer.size());
+ bytes_written =
+ base::AppendToFile(dump_path_,
+ reinterpret_cast<const char*>(
+ vector_as_array(&compressed_buffer)),
+ compressed_buffer.size())
+ ? compressed_buffer.size()
+ : -1;
} else {
bytes_written = base::WriteFile(
dump_path_,
@@ -233,12 +237,10 @@ class WebRtcRtpDumpWriter::FileThreadWorker {
memset(&stream_, 0, sizeof(z_stream));
DCHECK(!output_buffer.empty());
- int bytes_written =
- base::AppendToFile(dump_path_,
- reinterpret_cast<const char*>(&output_buffer[0]),
- output_buffer.size());
-
- return bytes_written > 0;
+ return base::AppendToFile(dump_path_,
+ reinterpret_cast<const char*>(
+ vector_as_array(&output_buffer)),
+ output_buffer.size());
}
const base::FilePath dump_path_;
« no previous file with comments | « chrome/browser/devtools/devtools_file_helper.cc ('k') | chrome/browser/media_galleries/linux/mtp_read_file_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698