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

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: sorin@, cpu@ review Created 7 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 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
22 namespace component_updater {
23
21 class ComponentPatcher; 24 class ComponentPatcher;
22 25
23 class DeltaUpdateOp { 26 class DeltaUpdateOp {
24 public: 27 public:
25 28
26 DeltaUpdateOp(); 29 DeltaUpdateOp();
27 virtual ~DeltaUpdateOp(); 30 virtual ~DeltaUpdateOp();
28 31
29 // Parses, runs, and verifies the operation, returning an error code if an 32 // Parses, runs, and verifies the operation, returning an error code if an
30 // error is encountered, and DELTA_OK otherwise. In case of errors, 33 // error is encountered, and DELTA_OK otherwise. In case of errors,
31 // extended error information can be returned in the |error| parameter. 34 // extended error information can be returned in the |error| parameter.
32 ComponentUnpacker::Error Run( 35 component_updater::ComponentUnpacker::Error Run(
Sorin Jianu 2013/11/27 00:34:01 namespace needed here and below?
waffles 2013/11/27 01:26:43 Done.
33 base::DictionaryValue* command_args, 36 base::DictionaryValue* command_args,
34 const base::FilePath& input_dir, 37 const base::FilePath& input_dir,
35 const base::FilePath& unpack_dir, 38 const base::FilePath& unpack_dir,
36 ComponentPatcher* patcher, 39 ComponentPatcher* patcher,
37 ComponentInstaller* installer, 40 ComponentInstaller* installer,
38 int* error); 41 int* error);
39 42
40 protected: 43 protected:
41 std::string output_sha256_; 44 std::string output_sha256_;
42 base::FilePath output_abs_path_; 45 base::FilePath output_abs_path_;
43 46
44 private: 47 private:
45 ComponentUnpacker::Error CheckHash(); 48 component_updater::ComponentUnpacker::Error CheckHash();
46 49
47 // Subclasses must override DoParseArguments to parse operation-specific 50 // Subclasses must override DoParseArguments to parse operation-specific
48 // arguments. DoParseArguments returns DELTA_OK on success; any other code 51 // arguments. DoParseArguments returns DELTA_OK on success; any other code
49 // represents failure. 52 // represents failure.
50 virtual ComponentUnpacker::Error DoParseArguments( 53 virtual component_updater::ComponentUnpacker::Error DoParseArguments(
51 base::DictionaryValue* command_args, 54 base::DictionaryValue* command_args,
52 const base::FilePath& input_dir, 55 const base::FilePath& input_dir,
53 ComponentInstaller* installer) = 0; 56 ComponentInstaller* installer) = 0;
54 57
55 // Subclasses must override DoRun to actually perform the patching operation. 58 // Subclasses must override DoRun to actually perform the patching operation.
56 // DoRun returns DELTA_OK on success; any other code represents failure. 59 // DoRun returns DELTA_OK on success; any other code represents failure.
57 // Additional error information can be returned in the |error| parameter. 60 // Additional error information can be returned in the |error| parameter.
58 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 61 virtual component_updater::ComponentUnpacker::Error DoRun(
59 int* error) = 0; 62 ComponentPatcher* patcher,
63 int* error) = 0;
60 64
61 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp); 65 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp);
62 }; 66 };
63 67
64 // A 'copy' operation takes a file currently residing on the disk and moves it 68 // 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 69 // into the unpacking directory: this represents "no change" in the file being
66 // installed. 70 // installed.
67 class DeltaUpdateOpCopy : public DeltaUpdateOp { 71 class DeltaUpdateOpCopy : public DeltaUpdateOp {
68 public: 72 public:
69 DeltaUpdateOpCopy(); 73 DeltaUpdateOpCopy();
70 74
71 private: 75 private:
72 // Overrides of DeltaUpdateOp. 76 // Overrides of DeltaUpdateOp.
73 virtual ComponentUnpacker::Error DoParseArguments( 77 virtual component_updater::ComponentUnpacker::Error DoParseArguments(
74 base::DictionaryValue* command_args, 78 base::DictionaryValue* command_args,
75 const base::FilePath& input_dir, 79 const base::FilePath& input_dir,
76 ComponentInstaller* installer) OVERRIDE; 80 ComponentInstaller* installer) OVERRIDE;
77 81
78 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 82 virtual component_updater::ComponentUnpacker::Error DoRun(
79 int* error) OVERRIDE; 83 ComponentPatcher* patcher,
84 int* error) OVERRIDE;
80 85
81 base::FilePath input_abs_path_; 86 base::FilePath input_abs_path_;
82 87
83 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy); 88 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCopy);
84 }; 89 };
85 90
86 // A 'create' operation takes a full file that was sent in the delta update 91 // 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 92 // 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 93 // addition of a new file, or a file so different that no bandwidth could be
89 // saved by transmitting a differential update. 94 // saved by transmitting a differential update.
90 class DeltaUpdateOpCreate : public DeltaUpdateOp { 95 class DeltaUpdateOpCreate : public DeltaUpdateOp {
91 public: 96 public:
92 DeltaUpdateOpCreate(); 97 DeltaUpdateOpCreate();
93 98
94 private: 99 private:
95 // Overrides of DeltaUpdateOp. 100 // Overrides of DeltaUpdateOp.
96 virtual ComponentUnpacker::Error DoParseArguments( 101 virtual component_updater::ComponentUnpacker::Error DoParseArguments(
97 base::DictionaryValue* command_args, 102 base::DictionaryValue* command_args,
98 const base::FilePath& input_dir, 103 const base::FilePath& input_dir,
99 ComponentInstaller* installer) OVERRIDE; 104 ComponentInstaller* installer) OVERRIDE;
100 105
101 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 106 virtual component_updater::ComponentUnpacker::Error DoRun(
102 int* error) OVERRIDE; 107 ComponentPatcher* patcher,
108 int* error) OVERRIDE;
103 109
104 base::FilePath patch_abs_path_; 110 base::FilePath patch_abs_path_;
105 111
106 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate); 112 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpCreate);
107 }; 113 };
108 114
109 // A 'bsdiff' operation takes an existing file on disk, and a bsdiff- 115 // 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 116 // format patch file provided in the delta update package, and runs bsdiff
111 // to construct an output file in the unpacking directory. 117 // to construct an output file in the unpacking directory.
112 class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp { 118 class DeltaUpdateOpPatchBsdiff : public DeltaUpdateOp {
113 public: 119 public:
114 DeltaUpdateOpPatchBsdiff(); 120 DeltaUpdateOpPatchBsdiff();
115 121
116 private: 122 private:
117 // Overrides of DeltaUpdateOp. 123 // Overrides of DeltaUpdateOp.
118 virtual ComponentUnpacker::Error DoParseArguments( 124 virtual component_updater::ComponentUnpacker::Error DoParseArguments(
119 base::DictionaryValue* command_args, 125 base::DictionaryValue* command_args,
120 const base::FilePath& input_dir, 126 const base::FilePath& input_dir,
121 ComponentInstaller* installer) OVERRIDE; 127 ComponentInstaller* installer) OVERRIDE;
122 128
123 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 129 virtual component_updater::ComponentUnpacker::Error DoRun(
124 int* error) OVERRIDE; 130 ComponentPatcher* patcher,
131 int* error) OVERRIDE;
125 132
126 base::FilePath patch_abs_path_; 133 base::FilePath patch_abs_path_;
127 base::FilePath input_abs_path_; 134 base::FilePath input_abs_path_;
128 135
129 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff); 136 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchBsdiff);
130 }; 137 };
131 138
132 // A 'courgette' operation takes an existing file on disk, and a Courgette- 139 // 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 140 // format patch file provided in the delta update package, and runs Courgette
134 // to construct an output file in the unpacking directory. 141 // to construct an output file in the unpacking directory.
135 class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp { 142 class DeltaUpdateOpPatchCourgette : public DeltaUpdateOp {
136 public: 143 public:
137 DeltaUpdateOpPatchCourgette(); 144 DeltaUpdateOpPatchCourgette();
138 145
139 private: 146 private:
140 // Overrides of DeltaUpdateOp. 147 // Overrides of DeltaUpdateOp.
141 virtual ComponentUnpacker::Error DoParseArguments( 148 virtual component_updater::ComponentUnpacker::Error DoParseArguments(
142 base::DictionaryValue* command_args, 149 base::DictionaryValue* command_args,
143 const base::FilePath& input_dir, 150 const base::FilePath& input_dir,
144 ComponentInstaller* installer) OVERRIDE; 151 ComponentInstaller* installer) OVERRIDE;
145 152
146 virtual ComponentUnpacker::Error DoRun(ComponentPatcher* patcher, 153 virtual component_updater::ComponentUnpacker::Error DoRun(
147 int* error) OVERRIDE; 154 ComponentPatcher* patcher,
155 int* error) OVERRIDE;
148 156
149 base::FilePath patch_abs_path_; 157 base::FilePath patch_abs_path_;
150 base::FilePath input_abs_path_; 158 base::FilePath input_abs_path_;
151 159
152 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette); 160 DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOpPatchCourgette);
153 }; 161 };
154 162
155 // Factory function to create DeltaUpdateOp instances. 163 // Factory function to create DeltaUpdateOp instances.
156 DeltaUpdateOp* CreateDeltaUpdateOp(base::DictionaryValue* command); 164 DeltaUpdateOp* CreateDeltaUpdateOp(base::DictionaryValue* command);
157 165
166 } // namespace component_updater
167
158 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_ 168 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698