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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « SConstruct ('k') | buffered_file_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
7
8 #include <base/scoped_ptr.h>
9 #include <gtest/gtest_prod.h> // for FRIEND_TEST
10
11 #include "update_engine/file_writer.h"
12
13 // BufferedFileWriter is an implementation of FileWriter that buffers all data
14 // before passing it onto another FileWriter.
15
16 namespace chromeos_update_engine {
17
18 class BufferedFileWriter : public FileWriter {
19 public:
20 BufferedFileWriter(FileWriter* next, size_t buffer_size);
21 virtual ~BufferedFileWriter();
22
23 virtual int Open(const char* path, int flags, mode_t mode);
24 virtual ssize_t Write(const void* bytes, size_t count);
25 virtual int Close();
26
27 private:
28 FRIEND_TEST(BufferedFileWriterTest, CloseErrorTest);
29 FRIEND_TEST(BufferedFileWriterTest, CloseNoDataTest);
30 FRIEND_TEST(BufferedFileWriterTest, CloseWriteErrorTest);
31 FRIEND_TEST(BufferedFileWriterTest, ConstructorTest);
32 FRIEND_TEST(BufferedFileWriterTest, WriteBufferNoDataTest);
33 FRIEND_TEST(BufferedFileWriterTest, WriteBufferTest);
34 FRIEND_TEST(BufferedFileWriterTest, WriteErrorTest);
35 FRIEND_TEST(BufferedFileWriterTest, WriteTest);
36 FRIEND_TEST(BufferedFileWriterTest, WriteWrapBufferTest);
37
38 // If non-empty, sends the buffer to the next FileWriter.
39 ssize_t WriteBuffer();
40
41 // The FileWriter that we write all buffered data to.
42 FileWriter* const next_;
43
44 scoped_array<char> buffer_;
45 size_t buffer_size_;
46 size_t buffered_bytes_;
47
48 DISALLOW_COPY_AND_ASSIGN(BufferedFileWriter);
49 };
50
51 } // namespace chromeos_update_engine
52
53 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
OLDNEW
« 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