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

Side by Side Diff: src/platform/update_engine/extent_writer.h

Issue 1718001: AU: Class to perform delta updates. (Closed)
Patch Set: fixes for review Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__
7 7
8 #include <vector> 8 #include <vector>
9 #include "chromeos/obsolete_logging.h" 9 #include "chromeos/obsolete_logging.h"
10 #include "update_engine/update_metadata.pb.h" 10 #include "update_engine/update_metadata.pb.h"
11 #include "update_engine/utils.h" 11 #include "update_engine/utils.h"
12 12
13 // ExtentWriter is an abstract class which synchronously writes to a given 13 // ExtentWriter is an abstract class which synchronously writes to a given
14 // file descriptor at the extents given. 14 // file descriptor at the extents given.
15 15
16 namespace chromeos_update_engine { 16 namespace chromeos_update_engine {
17 17
18 // When an extent's start block is kSparseHole, that data written for that
19 // extent will be dropped rather than written to the unerlying fd.
20 const uint64 kSparseHole = kuint64max;
21
22 class ExtentWriter { 18 class ExtentWriter {
23 public: 19 public:
24 ExtentWriter() : end_called_(false) {} 20 ExtentWriter() : end_called_(false) {}
25 virtual ~ExtentWriter() { 21 virtual ~ExtentWriter() {
26 LOG_IF(ERROR, !end_called_) << "End() not called on ExtentWriter."; 22 LOG_IF(ERROR, !end_called_) << "End() not called on ExtentWriter.";
27 } 23 }
28 24
29 // Returns true on success. 25 // Returns true on success.
30 virtual bool Init(int fd, 26 virtual bool Init(int fd,
31 const std::vector<Extent>& extents, 27 const std::vector<Extent>& extents,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool Write(const void* bytes, size_t count); 62 bool Write(const void* bytes, size_t count);
67 bool EndImpl() { 63 bool EndImpl() {
68 return true; 64 return true;
69 } 65 }
70 66
71 private: 67 private:
72 int fd_; 68 int fd_;
73 69
74 size_t block_size_; 70 size_t block_size_;
75 // Bytes written into next_extent_index_ thus far 71 // Bytes written into next_extent_index_ thus far
76 uint64 extent_bytes_written_; 72 uint64_t extent_bytes_written_;
77 std::vector<Extent> extents_; 73 std::vector<Extent> extents_;
78 // The next call to write should correspond to extents_[next_extent_index_] 74 // The next call to write should correspond to extents_[next_extent_index_]
79 std::vector<Extent>::size_type next_extent_index_; 75 std::vector<Extent>::size_type next_extent_index_;
80 }; 76 };
81 77
82 // Takes an underlying ExtentWriter to which all operations are delegated. 78 // Takes an underlying ExtentWriter to which all operations are delegated.
83 // When End() is called, ZeroPadExtentWriter ensures that the total number 79 // When End() is called, ZeroPadExtentWriter ensures that the total number
84 // of bytes written is a multiple of block_size_. If not, it writes zeros 80 // of bytes written is a multiple of block_size_. If not, it writes zeros
85 // to pad as needed. 81 // to pad as needed.
86 82
(...skipping 29 matching lines...) Expand all
116 112
117 private: 113 private:
118 ExtentWriter* underlying_extent_writer_; // The underlying ExtentWriter. 114 ExtentWriter* underlying_extent_writer_; // The underlying ExtentWriter.
119 size_t block_size_; 115 size_t block_size_;
120 size_t bytes_written_mod_block_size_; 116 size_t bytes_written_mod_block_size_;
121 }; 117 };
122 118
123 } // namespace chromeos_update_engine 119 } // namespace chromeos_update_engine
124 120
125 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__ 121 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_EXTENT_WRITER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698