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

Unified Diff: buffered_file_writer.h

Issue 3471006: AU: Speed up updates by using buffered writes. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: update comment Created 10 years, 3 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
« no previous file with comments | « SConstruct ('k') | buffered_file_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: buffered_file_writer.h
diff --git a/buffered_file_writer.h b/buffered_file_writer.h
new file mode 100644
index 0000000000000000000000000000000000000000..0457285c4584dc4da1ceaf46219bdc711e5a9d5c
--- /dev/null
+++ b/buffered_file_writer.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
+
+#include <base/scoped_ptr.h>
+#include <gtest/gtest_prod.h> // for FRIEND_TEST
+
+#include "update_engine/file_writer.h"
+
+// BufferedFileWriter is an implementation of FileWriter that buffers all data
+// before passing it onto another FileWriter.
+
+namespace chromeos_update_engine {
+
+class BufferedFileWriter : public FileWriter {
+ public:
+ BufferedFileWriter(FileWriter* next, size_t buffer_size);
+ virtual ~BufferedFileWriter();
+
+ virtual int Open(const char* path, int flags, mode_t mode);
+ virtual ssize_t Write(const void* bytes, size_t count);
+ virtual int Close();
+
+ private:
+ FRIEND_TEST(BufferedFileWriterTest, CloseErrorTest);
+ FRIEND_TEST(BufferedFileWriterTest, CloseNoDataTest);
+ FRIEND_TEST(BufferedFileWriterTest, CloseWriteErrorTest);
+ FRIEND_TEST(BufferedFileWriterTest, ConstructorTest);
+ FRIEND_TEST(BufferedFileWriterTest, WriteBufferNoDataTest);
+ FRIEND_TEST(BufferedFileWriterTest, WriteBufferTest);
+ FRIEND_TEST(BufferedFileWriterTest, WriteErrorTest);
+ FRIEND_TEST(BufferedFileWriterTest, WriteTest);
+ FRIEND_TEST(BufferedFileWriterTest, WriteWrapBufferTest);
+
+ // If non-empty, sends the buffer to the next FileWriter.
+ ssize_t WriteBuffer();
+
+ // The FileWriter that we write all buffered data to.
+ FileWriter* const next_;
+
+ scoped_array<char> buffer_;
+ size_t buffer_size_;
+ size_t buffered_bytes_;
+
+ DISALLOW_COPY_AND_ASSIGN(BufferedFileWriter);
+};
+
+} // namespace chromeos_update_engine
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
« no previous file with comments | « SConstruct ('k') | buffered_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698