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

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

Issue 492008: AU: Try delta updates first, then full updates (Closed)
Patch Set: use mkstemp Created 11 years 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 Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium 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_DIFF_GENERATOR_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
7 7
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "update_engine/file_writer.h" 14 #include "update_engine/file_writer.h"
14 #include "update_engine/update_metadata.pb.h" 15 #include "update_engine/update_metadata.pb.h"
15 16
16 namespace chromeos_update_engine { 17 namespace chromeos_update_engine {
17 18
18 class DeltaDiffGenerator { 19 class DeltaDiffGenerator {
19 public: 20 public:
20 // Encodes the metadata at new_path recursively into a DeltaArchiveManifest 21 // Encodes the metadata at new_path recursively into a DeltaArchiveManifest
21 // protobuf object. This will only read the filesystem. Children will 22 // protobuf object. This will only read the filesystem. Children will
22 // be recorded recursively iff they are on the same device as their 23 // be recorded recursively iff they are on the same device as their
23 // parent. 24 // parent.
24 // This will set all fields in the DeltaArchiveManifest except for 25 // This will set all fields in the DeltaArchiveManifest except for
25 // DeltaArchiveManifest_File_data_* as those are set only when writing 26 // DeltaArchiveManifest_File_data_* as those are set only when writing
26 // the actual delta file to disk. 27 // the actual delta file to disk.
27 // Caller is responsible for freeing the returned value. 28 // Caller is responsible for freeing the returned value.
28 // Returns NULL on failure. 29 // Returns NULL on failure.
29 static DeltaArchiveManifest* EncodeMetadataToProtoBuffer( 30 static DeltaArchiveManifest* EncodeMetadataToProtoBuffer(
30 const char* new_path); 31 const char* new_path);
31 32
32 // Takes a DeltaArchiveManifest as given from EncodeMetadataToProtoBuffer(), 33 // Takes a DeltaArchiveManifest as given from EncodeMetadataToProtoBuffer(),
33 // fill in the missing fields (DeltaArchiveManifest_File_data_*), and 34 // fill in the missing fields (DeltaArchiveManifest_File_data_*), and
34 // write the full delta out to the output file. 35 // write the full delta out to the output file.
36 // Any paths in nondiff_paths will be included in full, rather than
37 // as a diff. This is useful for files that change during postinstall, since
38 // future updates can't depend on them having remaining unchanged.
35 // Returns true on success. 39 // Returns true on success.
36 // If non-empty, the device at force_compress_dev_path will be compressed. 40 // If non-empty, the device at force_compress_dev_path will be compressed.
37 static bool EncodeDataToDeltaFile(DeltaArchiveManifest* archive, 41 static bool EncodeDataToDeltaFile(
38 const std::string& old_path, 42 DeltaArchiveManifest* archive,
39 const std::string& new_path, 43 const std::string& old_path,
40 const std::string& out_file, 44 const std::string& new_path,
41 const std::string& force_compress_dev_path); 45 const std::string& out_file,
42 46 const std::set<std::string>& nondiff_paths,
47 const std::string& force_compress_dev_path);
48
43 private: 49 private:
44 // These functions encode all the data about a file that's not already 50 // These functions encode all the data about a file that's not already
45 // stored in the DeltaArchiveManifest message into the vector 'out'. 51 // stored in the DeltaArchiveManifest message into the vector 'out'.
46 // They all return true on success. 52 // They all return true on success.
47 53
48 // EncodeLink stores the path the symlink points to. 54 // EncodeLink stores the path the symlink points to.
49 static bool EncodeLink(const std::string& path, std::vector<char>* out); 55 static bool EncodeLink(const std::string& path, std::vector<char>* out);
50 // EncodeDev stores the major and minor device numbers. 56 // EncodeDev stores the major and minor device numbers.
51 // Specifically it writes a LinuxDevice message. 57 // Specifically it writes a LinuxDevice message.
52 static bool EncodeDev( 58 static bool EncodeDev(
53 const struct stat& stbuf, std::vector<char>* out, 59 const struct stat& stbuf, std::vector<char>* out,
54 DeltaArchiveManifest_File_DataFormat* format, 60 DeltaArchiveManifest_File_DataFormat* format,
55 bool force_compression); 61 bool force_compression);
56 // EncodeFile stores the full data, gzipped data, or a binary diff from 62 // EncodeFile stores the full data, gzipped data, or a binary diff from
57 // the old data. out_data_format will be set to the method used. 63 // the old data. out_data_format will be set to the method used.
58 static bool EncodeFile(const std::string& old_dir, 64 static bool EncodeFile(const std::string& old_dir,
59 const std::string& new_dir, 65 const std::string& new_dir,
60 const std::string& file_name, 66 const std::string& file_name,
67 const bool avoid_diff,
61 DeltaArchiveManifest_File_DataFormat* out_data_format, 68 DeltaArchiveManifest_File_DataFormat* out_data_format,
62 std::vector<char>* out); 69 std::vector<char>* out,
70 bool* no_change);
63 71
72 // nondiff_paths is passed in to EncodeDataToDeltaFile() with
73 // paths relative to the installed system (e.g. /etc/fstab), but
74 // WriteFileDiffsToDeltaFile requires always_full_target_paths to be
75 // the entire path of the new file.
64 // If non-empty, the device at force_compress_dev_path will be compressed. 76 // If non-empty, the device at force_compress_dev_path will be compressed.
65 static bool WriteFileDiffsToDeltaFile( 77 static bool WriteFileDiffsToDeltaFile(
66 DeltaArchiveManifest* archive, 78 DeltaArchiveManifest* archive,
67 DeltaArchiveManifest_File* file, 79 DeltaArchiveManifest_File* file,
68 const std::string& file_name, 80 const std::string& file_name,
69 const std::string& old_path, 81 const std::string& old_path,
70 const std::string& new_path, 82 const std::string& new_path,
71 FileWriter* out_file_writer, 83 FileWriter* out_file_writer,
72 int* out_file_length, 84 int* out_file_length,
85 std::set<std::string> always_full_target_paths,
73 const std::string& force_compress_dev_path); 86 const std::string& force_compress_dev_path);
74 87
75 // This should never be constructed 88 // This should never be constructed
76 DISALLOW_IMPLICIT_CONSTRUCTORS(DeltaDiffGenerator); 89 DISALLOW_IMPLICIT_CONSTRUCTORS(DeltaDiffGenerator);
77 }; 90 };
78 91
79 }; // namespace chromeos_update_engine 92 }; // namespace chromeos_update_engine
80 93
81 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__ 94 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_DIFF_GENERATOR_H__
OLDNEW
« no previous file with comments | « src/platform/update_engine/action_unittest.cc ('k') | src/platform/update_engine/delta_diff_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698