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

Side by Side Diff: delta_performer.h

Issue 3541016: AU: Optimize checkpointing a bit and decide on new update vs. resume. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: fix copyrights Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | delta_performer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 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 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_DELTA_PERFORMER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
7 7
8 #include <inttypes.h> 8 #include <inttypes.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 24
25 class DeltaPerformer : public FileWriter { 25 class DeltaPerformer : public FileWriter {
26 public: 26 public:
27 DeltaPerformer(PrefsInterface* prefs) 27 DeltaPerformer(PrefsInterface* prefs)
28 : prefs_(prefs), 28 : prefs_(prefs),
29 fd_(-1), 29 fd_(-1),
30 kernel_fd_(-1), 30 kernel_fd_(-1),
31 manifest_valid_(false), 31 manifest_valid_(false),
32 next_operation_num_(0), 32 next_operation_num_(0),
33 buffer_offset_(0), 33 buffer_offset_(0),
34 last_updated_buffer_offset_(kuint64max),
34 block_size_(0) {} 35 block_size_(0) {}
35 36
36 // Opens the kernel. Should be called before or after Open(), but before 37 // Opens the kernel. Should be called before or after Open(), but before
37 // Write(). The kernel file will be close()d when Close() is called. 38 // Write(). The kernel file will be close()d when Close() is called.
38 bool OpenKernel(const char* kernel_path); 39 bool OpenKernel(const char* kernel_path);
39 40
40 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be 41 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be
41 // Open()ed again. 42 // Open()ed again.
42 int Open(const char* path, int flags, mode_t mode); 43 int Open(const char* path, int flags, mode_t mode);
43 44
(...skipping 21 matching lines...) Expand all
65 // Also, an extent starting at kSparseHole, appears as -1 in the string. 66 // Also, an extent starting at kSparseHole, appears as -1 in the string.
66 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1}, 67 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
67 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13, 68 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
68 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083" 69 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
69 static bool ExtentsToBsdiffPositionsString( 70 static bool ExtentsToBsdiffPositionsString(
70 const google::protobuf::RepeatedPtrField<Extent>& extents, 71 const google::protobuf::RepeatedPtrField<Extent>& extents,
71 uint64_t block_size, 72 uint64_t block_size,
72 uint64_t full_length, 73 uint64_t full_length,
73 std::string* positions_string); 74 std::string* positions_string);
74 75
76 // Returns true if a previous update attempt can be continued based on the
77 // persistent preferences and the new update check response hash.
78 static bool CanResumeUpdate(PrefsInterface* prefs,
79 std::string update_check_response_hash);
80
81 // Resets the persistent update progress state to indicate that an update
82 // can't be resumed. Returns true on success, false otherwise.
83 static bool ResetUpdateProgress(PrefsInterface* prefs);
84
75 private: 85 private:
76 // Returns true if enough of the delta file has been passed via Write() 86 // Returns true if enough of the delta file has been passed via Write()
77 // to be able to perform a given install operation. 87 // to be able to perform a given install operation.
78 bool CanPerformInstallOperation( 88 bool CanPerformInstallOperation(
79 const DeltaArchiveManifest_InstallOperation& operation); 89 const DeltaArchiveManifest_InstallOperation& operation);
80 90
81 // Returns true on success. 91 // Returns true on success.
82 bool PerformInstallOperation( 92 bool PerformInstallOperation(
83 const DeltaArchiveManifest_InstallOperation& operation); 93 const DeltaArchiveManifest_InstallOperation& operation);
84 94
(...skipping 10 matching lines...) Expand all
95 105
96 // Returns true if the payload signature message has been extracted from 106 // Returns true if the payload signature message has been extracted from
97 // |operation|, false otherwise. 107 // |operation|, false otherwise.
98 bool ExtractSignatureMessage( 108 bool ExtractSignatureMessage(
99 const DeltaArchiveManifest_InstallOperation& operation); 109 const DeltaArchiveManifest_InstallOperation& operation);
100 110
101 // Discard |count| bytes from the beginning of buffer_. If |do_hash| is true, 111 // Discard |count| bytes from the beginning of buffer_. If |do_hash| is true,
102 // updates the hash calculator with these bytes before discarding them. 112 // updates the hash calculator with these bytes before discarding them.
103 void DiscardBufferHeadBytes(size_t count, bool do_hash); 113 void DiscardBufferHeadBytes(size_t count, bool do_hash);
104 114
105 bool ResetUpdateProgress(); 115 // Checkpoints the update progress into persistent storage to allow this
116 // update attempt to be resumed after reboot.
106 bool CheckpointUpdateProgress(); 117 bool CheckpointUpdateProgress();
107 118
108 // Update Engine preference store. 119 // Update Engine preference store.
109 PrefsInterface* prefs_; 120 PrefsInterface* prefs_;
110 121
111 // File descriptor of open device. 122 // File descriptor of open device.
112 int fd_; 123 int fd_;
113 124
114 // File descriptor of the kernel device 125 // File descriptor of the kernel device
115 int kernel_fd_; 126 int kernel_fd_;
116 127
117 std::string path_; // Path that fd_ refers to. 128 std::string path_; // Path that fd_ refers to.
118 std::string kernel_path_; // Path that kernel_fd_ refers to. 129 std::string kernel_path_; // Path that kernel_fd_ refers to.
119 130
120 DeltaArchiveManifest manifest_; 131 DeltaArchiveManifest manifest_;
121 bool manifest_valid_; 132 bool manifest_valid_;
122 133
123 // Index of the next operation to perform in the manifest. 134 // Index of the next operation to perform in the manifest.
124 int next_operation_num_; 135 int next_operation_num_;
125 136
126 // buffer_ is a window of the data that's been downloaded. At first, 137 // buffer_ is a window of the data that's been downloaded. At first,
127 // it contains the beginning of the download, but after the protobuf 138 // it contains the beginning of the download, but after the protobuf
128 // has been downloaded and parsed, it contains a sliding window of 139 // has been downloaded and parsed, it contains a sliding window of
129 // data blobs. 140 // data blobs.
130 std::vector<char> buffer_; 141 std::vector<char> buffer_;
131 // Offset of buffer_ in the binary blobs section of the update. 142 // Offset of buffer_ in the binary blobs section of the update.
132 uint64_t buffer_offset_; 143 uint64_t buffer_offset_;
133 144
145 // Last |buffer_offset_| value updated as part of the progress update.
146 uint64_t last_updated_buffer_offset_;
147
134 // The block size (parsed from the manifest). 148 // The block size (parsed from the manifest).
135 uint32_t block_size_; 149 uint32_t block_size_;
136 150
137 // Calculate the payload hash to verify against the signed hash. 151 // Calculate the payload hash to verify against the signed hash.
138 OmahaHashCalculator hash_calculator_; 152 OmahaHashCalculator hash_calculator_;
139 153
140 // Signatures message blob extracted directly from the payload. 154 // Signatures message blob extracted directly from the payload.
141 std::vector<char> signatures_message_data_; 155 std::vector<char> signatures_message_data_;
142 156
143 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); 157 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
144 }; 158 };
145 159
146 } // namespace chromeos_update_engine 160 } // namespace chromeos_update_engine
147 161
148 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 162 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
OLDNEW
« no previous file with comments | « no previous file | delta_performer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698