OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium 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 CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_INTERNAL_H_ | |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_INTERNAL_H_ | |
7 | |
8 #include <string> | |
9 #include "base/basictypes.h" | |
10 #include "base/files/file_path.h" | |
11 #include "base/values.h" | |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
I am guessing the you can fwd declare Value instea
waffles
2013/06/13 20:55:04
Done.
| |
12 #include "chrome/browser/component_updater/component_patcher.h" | |
13 | |
14 class ComponentInstaller; | |
15 | |
16 class DeltaUpdateOp { | |
17 public: | |
18 // These constants refer to the position of arguments in the command list. | |
19 enum ArgumentPos { | |
20 kDeltaOutputPath = 0, | |
21 kDeltaOutputSha256 = 1, | |
22 kDeltaOperation = 2, | |
23 }; | |
24 | |
25 DeltaUpdateOp(); | |
26 virtual ~DeltaUpdateOp(); | |
27 | |
28 // Parses, runs, and verifies the operation, returning an error code if an | |
29 // error is encountered, and DELTA_OK otherwise. In case of errors, | |
30 // extended error information can be returned in the |error| parameter. | |
31 DeltaUpdateResult Run( | |
32 base::ListValue* command_args, | |
33 const base::FilePath& input_dir, | |
34 const base::FilePath& unpack_dir, | |
35 ComponentPatcher* patcher, | |
36 ComponentInstaller* installer, | |
37 int* error); | |
38 | |
39 protected: | |
40 std::string output_sha256_; // The SHA-256 hash of the output file. | |
41 base::FilePath output_abs_path_; // The relative location for the output. | |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
prefer comments above each line. In this particula
waffles
2013/06/13 20:55:04
Done.
| |
42 | |
43 private: | |
44 DeltaUpdateResult CheckHash(); | |
45 | |
46 // Subclasses must override DoParseArguments to parse operation-specific | |
47 // arguments. DoParseArguments returns DELTA_OK on success; any other code | |
48 // represents failure. | |
49 virtual DeltaUpdateResult DoParseArguments(base::ListValue* command_args, | |
50 const base::FilePath& input_dir, | |
51 ComponentInstaller* installer) = 0; | |
52 | |
53 // Subclasses must override DoRun to actually perform the patching operation. | |
54 // DoRun returns DELTA_OK on success; any other code represents failure. | |
55 // Additional error information can be returned in the |error| parameter. | |
56 virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, int* error) = 0; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp); | |
59 }; | |
60 | |
61 // A 'copy' operation takes a file currently residing on the disk and moves it | |
62 // into the unpacking directory: this represents "no change" in the file being | |
63 // installed. | |
64 class DeltaUpdateOpCopy : public DeltaUpdateOp { | |
65 public: | |
cpu_(ooo_6.6-7.5)
2013/05/29 20:06:44
since DeltaUpdateOp::ArgumentPos is in scope here
waffles
2013/06/13 20:55:04
Done.
| |
66 enum ArgumentPos { | |
67 kDeltaFrom = 3, | |
68 }; | |
69 | |
70 DeltaUpdateOpCopy(); | |
71 | |
72 private: | |
73 // Overrides of DeltaUpdateOp. | |
74 virtual DeltaUpdateResult DoParseArguments( | |
75 base::ListValue* command_args, | |
76 const base::FilePath& input_dir, | |
77 ComponentInstaller* installer) OVERRIDE; | |
78 | |
79 virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, | |
80 int* error) OVERRIDE; | |
81 | |
82 base::FilePath input_abs_path_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy); | |
85 }; | |
86 | |
87 // A 'create' operation takes a full file that was sent in the delta update | |
88 // archive and moves it into the unpacking directory: this represents the | |
89 // addition of a new file, or a file so different that no bandwidth could be | |
90 // saved by transmitting a differential update. | |
91 class DeltaUpdateOpCreate : public DeltaUpdateOp { | |
92 public: | |
93 enum ArgumentPos { | |
94 kDeltaPatch = 3, | |
95 }; | |
96 | |
97 DeltaUpdateOpCreate(); | |
98 | |
99 private: | |
100 // Overrides of DeltaUpdateOp. | |
101 virtual DeltaUpdateResult DoParseArguments( | |
102 base::ListValue* command_args, | |
103 const base::FilePath& input_dir, | |
104 ComponentInstaller* installer) OVERRIDE; | |
105 | |
106 virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, | |
107 int* error) OVERRIDE; | |
108 | |
109 base::FilePath patch_abs_path_; | |
110 | |
111 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate); | |
112 }; | |
113 | |
114 // A 'bsdiff' operation takes an existing file on disk, and a bsdiff- | |
115 // format patch file provided in the delta update package, and runs bsdiff | |
116 // to construct an output file in the unpacking directory. | |
117 class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp { | |
118 public: | |
119 enum ArgumentPos { | |
120 kDeltaFrom = 3, | |
121 kDeltaPatch = 4, | |
122 }; | |
123 | |
124 DeltaUpdateOpPatchBsdiff(); | |
125 | |
126 private: | |
127 // Overrides of DeltaUpdateOp. | |
128 virtual DeltaUpdateResult DoParseArguments( | |
129 base::ListValue* command_args, | |
130 const base::FilePath& input_dir, | |
131 ComponentInstaller* installer) OVERRIDE; | |
132 | |
133 virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, | |
134 int* error) OVERRIDE; | |
135 | |
136 base::FilePath patch_abs_path_; | |
137 base::FilePath input_abs_path_; | |
138 | |
139 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff); | |
140 }; | |
141 | |
142 // A 'courgette' operation takes an existing file on disk, and a Courgette- | |
143 // format patch file provided in the delta update package, and runs Courgette | |
144 // to construct an output file in the unpacking directory. | |
145 class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp { | |
146 public: | |
147 enum ArgumentPos { | |
148 kDeltaFrom = 3, | |
149 kDeltaPatch = 4, | |
150 }; | |
151 | |
152 DeltaUpdateOpPatchCourgette(); | |
153 | |
154 private: | |
155 // Overrides of DeltaUpdateOp. | |
156 virtual DeltaUpdateResult DoParseArguments( | |
157 base::ListValue* command_args, | |
158 const base::FilePath& input_dir, | |
159 ComponentInstaller* installer) OVERRIDE; | |
160 | |
161 virtual DeltaUpdateResult DoRun(ComponentPatcher* patcher, | |
162 int* error) OVERRIDE; | |
163 | |
164 base::FilePath patch_abs_path_; | |
165 base::FilePath input_abs_path_; | |
166 | |
167 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette); | |
168 }; | |
169 | |
170 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_INTERNAL_H_ | |
171 | |
OLD | NEW |