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

Side by Side Diff: chrome/browser/component_updater/component_patcher_operation.h

Issue 25883006: Support asynchronous patching operations in the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tests
Patch Set: Threading model changes. Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_ 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_ 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
11 #include "chrome/browser/component_updater/component_unpacker.h" 12 #include "chrome/browser/component_updater/component_unpacker.h"
12 13
13 namespace base { 14 namespace base {
14 15
15 class FilePath;
16 class DictionaryValue; 16 class DictionaryValue;
17 17
18 } // namespace base 18 } // namespace base
19 19
20 class ComponentInstaller; 20 class ComponentInstaller;
21 class ComponentPatcher; 21 class ComponentPatcher;
22 22
23 class DeltaUpdateOp { 23 class DeltaUpdateOp {
24 public: 24 public:
25 25
26 DeltaUpdateOp(); 26 DeltaUpdateOp();
27 virtual ~DeltaUpdateOp(); 27 virtual ~DeltaUpdateOp();
28 28
29 // Parses, runs, and verifies the operation, returning an error code if an 29 // Parses, runs, and verifies the operation, returning an error code if an
30 // error is encountered, and DELTA_OK otherwise. In case of errors, 30 // error is encountered, and DELTA_OK otherwise. In case of errors,
31 // extended error information can be returned in the |error| parameter. 31 // extended error information can be returned in the |error| parameter.
32 ComponentUnpacker::Error Run( 32 component_updater::Error Run(
33 base::DictionaryValue* command_args, 33 base::DictionaryValue* command_args,
34 const base::FilePath& input_dir, 34 const base::FilePath& input_dir,
35 const base::FilePath& unpack_dir, 35 const base::FilePath& unpack_dir,
36 ComponentPatcher* patcher, 36 ComponentPatcher* patcher,
37 ComponentInstaller* installer, 37 ComponentInstaller* installer,
38 int* error); 38 int* error);
39 39
40 protected: 40 protected:
41 std::string output_sha256_; 41 std::string output_sha256_;
42 base::FilePath output_abs_path_; 42 base::FilePath output_abs_path_;
43 43
44 private: 44 private:
45 ComponentUnpacker::Error CheckHash(); 45 component_updater::Error CheckHash();
46 46
47 // Subclasses must override DoParseArguments to parse operation-specific 47 // Subclasses must override DoParseArguments to parse operation-specific
48 // arguments. DoParseArguments returns DELTA_OK on success; any other code 48 // arguments. DoParseArguments returns DELTA_OK on success; any other code
49 // represents failure. 49 // represents failure.
50 virtual ComponentUnpacker::Error DoParseArguments( 50 virtual component_updater::Error DoParseArguments(
51 base::DictionaryValue* command_args, 51 base::DictionaryValue* command_args,
52 const base::FilePath& input_dir, 52 const base::FilePath& input_dir,
53 ComponentInstaller* installer) = 0; 53 ComponentInstaller* installer) = 0;
54 54
55 // Subclasses must override DoRun to actually perform the patching operation. 55 // Subclasses must override DoRun to actually perform the patching operation.
56 // DoRun returns DELTA_OK on success; any other code represents failure. 56 // DoRun returns DELTA_OK on success; any other code represents failure.
57 // Additional error information can be returned in the |error| parameter. 57 // Additional error information can be returned in the |error| parameter.
58 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 58 virtual component_updater::Error DoRun(ComponentPatcher* patcher,
59 int* error) = 0; 59 int* error) = 0;
60 60
61 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp); 61 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp);
62 }; 62 };
63 63
64 // A 'copy' operation takes a file currently residing on the disk and moves it 64 // A 'copy' operation takes a file currently residing on the disk and moves it
65 // into the unpacking directory: this represents "no change" in the file being 65 // into the unpacking directory: this represents "no change" in the file being
66 // installed. 66 // installed.
67 class DeltaUpdateOpCopy : public DeltaUpdateOp { 67 class DeltaUpdateOpCopy : public DeltaUpdateOp {
68 public: 68 public:
69 DeltaUpdateOpCopy(); 69 DeltaUpdateOpCopy();
70 70
71 private: 71 private:
72 // Overrides of DeltaUpdateOp. 72 // Overrides of DeltaUpdateOp.
73 virtual ComponentUnpacker::Error DoParseArguments( 73 virtual component_updater::Error DoParseArguments(
74 base::DictionaryValue* command_args, 74 base::DictionaryValue* command_args,
75 const base::FilePath& input_dir, 75 const base::FilePath& input_dir,
76 ComponentInstaller* installer) OVERRIDE; 76 ComponentInstaller* installer) OVERRIDE;
77 77
78 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 78 virtual component_updater::Error DoRun(ComponentPatcher* patcher,
79 int* error) OVERRIDE; 79 int* error) OVERRIDE;
80 80
81 base::FilePath input_abs_path_; 81 base::FilePath input_abs_path_;
82 82
83 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy); 83 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy);
84 }; 84 };
85 85
86 // A 'create' operation takes a full file that was sent in the delta update 86 // A 'create' operation takes a full file that was sent in the delta update
87 // archive and moves it into the unpacking directory: this represents the 87 // archive and moves it into the unpacking directory: this represents the
88 // addition of a new file, or a file so different that no bandwidth could be 88 // addition of a new file, or a file so different that no bandwidth could be
89 // saved by transmitting a differential update. 89 // saved by transmitting a differential update.
90 class DeltaUpdateOpCreate : public DeltaUpdateOp { 90 class DeltaUpdateOpCreate : public DeltaUpdateOp {
91 public: 91 public:
92 DeltaUpdateOpCreate(); 92 DeltaUpdateOpCreate();
93 93
94 private: 94 private:
95 // Overrides of DeltaUpdateOp. 95 // Overrides of DeltaUpdateOp.
96 virtual ComponentUnpacker::Error DoParseArguments( 96 virtual component_updater::Error DoParseArguments(
97 base::DictionaryValue* command_args, 97 base::DictionaryValue* command_args,
98 const base::FilePath& input_dir, 98 const base::FilePath& input_dir,
99 ComponentInstaller* installer) OVERRIDE; 99 ComponentInstaller* installer) OVERRIDE;
100 100
101 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 101 virtual component_updater::Error DoRun(ComponentPatcher* patcher,
102 int* error) OVERRIDE; 102 int* error) OVERRIDE;
103 103
104 base::FilePath patch_abs_path_; 104 base::FilePath patch_abs_path_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate); 106 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate);
107 }; 107 };
108 108
109 // A 'bsdiff' operation takes an existing file on disk, and a bsdiff- 109 // A 'bsdiff' operation takes an existing file on disk, and a bsdiff-
110 // format patch file provided in the delta update package, and runs bsdiff 110 // format patch file provided in the delta update package, and runs bsdiff
111 // to construct an output file in the unpacking directory. 111 // to construct an output file in the unpacking directory.
112 class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp { 112 class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp {
113 public: 113 public:
114 DeltaUpdateOpPatchBsdiff(); 114 DeltaUpdateOpPatchBsdiff();
115 115
116 private: 116 private:
117 // Overrides of DeltaUpdateOp. 117 // Overrides of DeltaUpdateOp.
118 virtual ComponentUnpacker::Error DoParseArguments( 118 virtual component_updater::Error DoParseArguments(
119 base::DictionaryValue* command_args, 119 base::DictionaryValue* command_args,
120 const base::FilePath& input_dir, 120 const base::FilePath& input_dir,
121 ComponentInstaller* installer) OVERRIDE; 121 ComponentInstaller* installer) OVERRIDE;
122 122
123 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 123 virtual component_updater::Error DoRun(ComponentPatcher* patcher,
124 int* error) OVERRIDE; 124 int* error) OVERRIDE;
125 125
126 base::FilePath patch_abs_path_; 126 base::FilePath patch_abs_path_;
127 base::FilePath input_abs_path_; 127 base::FilePath input_abs_path_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff); 129 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff);
130 }; 130 };
131 131
132 // A 'courgette' operation takes an existing file on disk, and a Courgette- 132 // A 'courgette' operation takes an existing file on disk, and a Courgette-
133 // format patch file provided in the delta update package, and runs Courgette 133 // format patch file provided in the delta update package, and runs Courgette
134 // to construct an output file in the unpacking directory. 134 // to construct an output file in the unpacking directory.
135 class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp { 135 class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp {
136 public: 136 public:
137 DeltaUpdateOpPatchCourgette(); 137 DeltaUpdateOpPatchCourgette();
138 138
139 private: 139 private:
140 // Overrides of DeltaUpdateOp. 140 // Overrides of DeltaUpdateOp.
141 virtual ComponentUnpacker::Error DoParseArguments( 141 virtual component_updater::Error DoParseArguments(
142 base::DictionaryValue* command_args, 142 base::DictionaryValue* command_args,
143 const base::FilePath& input_dir, 143 const base::FilePath& input_dir,
144 ComponentInstaller* installer) OVERRIDE; 144 ComponentInstaller* installer) OVERRIDE;
145 145
146 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 146 virtual component_updater::Error DoRun(ComponentPatcher* patcher,
147 int* error) OVERRIDE; 147 int* error) OVERRIDE;
148 148
149 base::FilePath patch_abs_path_; 149 base::FilePath patch_abs_path_;
150 base::FilePath input_abs_path_; 150 base::FilePath input_abs_path_;
151 151
152 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette); 152 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette);
153 }; 153 };
154 154
155 // Factory function to create DeltaUpdateOp instances. 155 // Factory function to create DeltaUpdateOp instances.
156 DeltaUpdateOp* CreateDeltaUpdateOp(base::DictionaryValue* command); 156 DeltaUpdateOp* CreateDeltaUpdateOp(base::DictionaryValue* command);
157 157
158 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_ 158 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698