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

Side by Side Diff: chrome/browser/component_updater/component_patcher.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 // Component updates can be either differential updates or full updates. 5 // Component updates can be either differential updates or full updates.
6 // Full updates come in CRX format; differential updates come in CRX-style 6 // Full updates come in CRX format; differential updates come in CRX-style
7 // archives, but have a different magic number. They contain "commands.json", a 7 // archives, but have a different magic number. They contain "commands.json", a
8 // list of commands for the patcher to follow. The patcher uses these commands, 8 // list of commands for the patcher to follow. The patcher uses these commands,
9 // the other files in the archive, and the files from the existing installation 9 // the other files in the archive, and the files from the existing installation
10 // of the component to create the contents of a full update, which is then 10 // of the component to create the contents of a full update, which is then
(...skipping 20 matching lines...) Expand all
31 #include "base/basictypes.h" 31 #include "base/basictypes.h"
32 #include "base/compiler_specific.h" 32 #include "base/compiler_specific.h"
33 #include "chrome/browser/component_updater/component_unpacker.h" 33 #include "chrome/browser/component_updater/component_unpacker.h"
34 34
35 namespace base { 35 namespace base {
36 class FilePath; 36 class FilePath;
37 } 37 }
38 38
39 class ComponentInstaller; 39 class ComponentInstaller;
40 40
41 namespace component_updater {
42
41 // Applies a delta patch to a single file. Specifically, creates a file at 43 // Applies a delta patch to a single file. Specifically, creates a file at
42 // |output_file| using |input_file| patched according to the algorithm 44 // |output_file| using |input_file| patched according to the algorithm
43 // specified by |patch_type| using |patch_file|. Sets the value of error to 45 // specified by |patch_type| using |patch_file|. Sets the value of error to
44 // the error code of the failing patch operation, if there is such a failure. 46 // the error code of the failing patch operation, if there is such a failure.
45 class ComponentPatcher { 47 class ComponentPatcher {
46 public: 48 public:
47 // The type of a patch file. 49 // The type of a patch file.
48 enum PatchType { 50 enum PatchType {
49 kPatchTypeUnknown, 51 kPatchTypeUnknown,
50 kPatchTypeCourgette, 52 kPatchTypeCourgette,
51 kPatchTypeBsdiff, 53 kPatchTypeBsdiff,
52 }; 54 };
53 55
54 virtual ComponentUnpacker::Error Patch(PatchType patch_type, 56 virtual ComponentUnpacker::Error Patch(
55 const base::FilePath& input_file, 57 PatchType patch_type,
56 const base::FilePath& patch_file, 58 const base::FilePath& input_file,
57 const base::FilePath& output_file, 59 const base::FilePath& patch_file,
58 int* error) = 0; 60 const base::FilePath& output_file,
61 int* error) = 0;
59 virtual ~ComponentPatcher() {} 62 virtual ~ComponentPatcher() {}
60 }; 63 };
61 64
62 class ComponentPatcherCrossPlatform : public ComponentPatcher { 65 class ComponentPatcherCrossPlatform : public ComponentPatcher {
63 public: 66 public:
64 ComponentPatcherCrossPlatform(); 67 ComponentPatcherCrossPlatform();
65 virtual ComponentUnpacker::Error Patch(PatchType patch_type, 68 virtual ComponentUnpacker::Error Patch(
66 const base::FilePath& input_file, 69 PatchType patch_type,
67 const base::FilePath& patch_file, 70 const base::FilePath& input_file,
68 const base::FilePath& output_file, 71 const base::FilePath& patch_file,
69 int* error) OVERRIDE; 72 const base::FilePath& output_file,
73 int* error) OVERRIDE;
70 private: 74 private:
71 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); 75 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform);
72 }; 76 };
73 77
74 // This function takes an unpacked differential CRX (|input_dir|) and a 78 // This function takes an unpacked differential CRX (|input_dir|) and a
75 // component installer, and creates a new (non-differential) unpacked CRX, which 79 // component installer, and creates a new (non-differential) unpacked CRX, which
76 // is then installed normally. 80 // is then installed normally.
77 // The non-differential files are written into the |unpack_dir| directory. 81 // The non-differential files are written into the |unpack_dir| directory.
78 // Sets |error| to the error code of the first failing patch operation. 82 // When finished, calls the callback, passing error codes if any errors were
79 ComponentUnpacker::Error DifferentialUpdatePatch( 83 // encountered.
84 void DifferentialUpdatePatch(
80 const base::FilePath& input_dir, 85 const base::FilePath& input_dir,
81 const base::FilePath& unpack_dir, 86 const base::FilePath& unpack_dir,
82 ComponentPatcher* component_patcher, 87 ComponentPatcher* component_patcher,
83 ComponentInstaller* installer, 88 ComponentInstaller* installer,
84 int* error); 89 base::Callback<void(ComponentUnpacker::Error, int)>
90 callback);
91
92 } // namespace component_updater
85 93
86 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ 94 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698