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

Unified Diff: third_party/crashpad/crashpad/util/file/file_writer.h

Issue 2754553002: Update Crashpad to 18d70acf81df49cc10b00bcc67c1ec64e16bd9d0 (Closed)
Patch Set: Created 3 years, 9 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: third_party/crashpad/crashpad/util/file/file_writer.h
diff --git a/third_party/crashpad/crashpad/util/file/file_writer.h b/third_party/crashpad/crashpad/util/file/file_writer.h
index ed261ec5446ddc3d6cd8f1cec0d8869a5695e60f..007e5f3a59a64842ca06a3c5c7f9757bd0ac0284 100644
--- a/third_party/crashpad/crashpad/util/file/file_writer.h
+++ b/third_party/crashpad/crashpad/util/file/file_writer.h
@@ -167,6 +167,41 @@ class FileWriter : public FileWriterInterface {
DISALLOW_COPY_AND_ASSIGN(FileWriter);
};
+//! \brief A file writer backed by a standard input/output `FILE*`.
+//!
+//! This class accepts an already-open `FILE*`. It is not responsible for
+//! opening or closing this `FILE*`. Users of this class must ensure that the
+//! `FILE*` is closed appropriately elsewhere. Objects of this class may be used
+//! to write to `FILE*` objects not associated with filesystem-based files,
+//! although special attention should be paid to the Seek() method, which may
+//! not function on `FILE*` objects that do not refer to disk-based files.
+//!
+//! This class is expected to be used when other code is responsible for
+//! opening `FILE*` objects and already provides `FILE*` objects. A good use
+//! would be a WeakStdioFileWriter for `stdout`.
+class WeakStdioFileWriter : public FileWriterInterface {
+ public:
+ explicit WeakStdioFileWriter(FILE* file);
+ ~WeakStdioFileWriter() override;
+
+ // FileWriterInterface:
+ bool Write(const void* data, size_t size) override;
+ bool WriteIoVec(std::vector<WritableIoVec>* iovecs) override;
+
+ // FileSeekerInterface:
+
+ //! \copydoc FileWriterInterface::Seek()
+ //!
+ //! \note This method is only guaranteed to function on `FILE*` objects
+ //! referring to disk-based files.
+ FileOffset Seek(FileOffset offset, int whence) override;
+
+ private:
+ FILE* file_; // weak
+
+ DISALLOW_COPY_AND_ASSIGN(WeakStdioFileWriter);
+};
+
} // namespace crashpad
#endif // CRASHPAD_UTIL_FILE_FILE_WRITER_H_
« no previous file with comments | « third_party/crashpad/crashpad/util/file/file_reader.cc ('k') | third_party/crashpad/crashpad/util/file/file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698