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

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: Clean up some merge leakage. Created 6 years, 11 months 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 11 matching lines...) Expand all
22 // 22 //
23 // After installation (diff or full), the component updater records "fp", the 23 // After installation (diff or full), the component updater records "fp", the
24 // fingerprint of the installed files, to later identify the existing files to 24 // fingerprint of the installed files, to later identify the existing files to
25 // the server so that a proper differential update can be provided next cycle. 25 // the server so that a proper differential update can be provided next cycle.
26 26
27 27
28 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ 28 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_
29 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ 29 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_
30 30
31 #include "base/basictypes.h" 31 #include "base/basictypes.h"
32 #include "base/callback_forward.h"
32 #include "base/compiler_specific.h" 33 #include "base/compiler_specific.h"
33 #include "chrome/browser/component_updater/component_unpacker.h" 34 #include "chrome/browser/component_updater/component_unpacker.h"
34 35
35 namespace base { 36 namespace base {
36 class FilePath; 37 class FilePath;
37 } 38 }
38 39
39 namespace component_updater { 40 namespace component_updater {
40 41
41 class ComponentInstaller; 42 class ComponentInstaller;
42 43
43 // Applies a delta patch to a single file. Specifically, creates a file at 44 // Applies a delta patch to a single file. Specifically, creates a file at
44 // |output_file| using |input_file| patched according to the algorithm 45 // |output_file| using |input_file| patched according to the algorithm
45 // specified by |patch_type| using |patch_file|. Sets the value of error to 46 // specified by |patch_type| using |patch_file|. Sets the value of error to
46 // the error code of the failing patch operation, if there is such a failure. 47 // the error code of the failing patch operation, if there is such a failure.
47 class ComponentPatcher { 48 class ComponentPatcher {
48 public: 49 public:
49 // The type of a patch file. 50 // The type of a patch file.
50 enum PatchType { 51 enum PatchType {
51 kPatchTypeUnknown, 52 kPatchTypeUnknown,
52 kPatchTypeCourgette, 53 kPatchTypeCourgette,
53 kPatchTypeBsdiff, 54 kPatchTypeBsdiff,
54 }; 55 };
55 56
56 virtual ComponentUnpacker::Error Patch(PatchType patch_type, 57 virtual ComponentUnpacker::Error Patch(
57 const base::FilePath& input_file, 58 PatchType patch_type,
58 const base::FilePath& patch_file, 59 const base::FilePath& input_file,
59 const base::FilePath& output_file, 60 const base::FilePath& patch_file,
60 int* error) = 0; 61 const base::FilePath& output_file,
62 int* error) = 0;
61 virtual ~ComponentPatcher() {} 63 virtual ~ComponentPatcher() {}
62 }; 64 };
63 65
64 class ComponentPatcherCrossPlatform : public ComponentPatcher { 66 class ComponentPatcherCrossPlatform : public ComponentPatcher {
65 public: 67 public:
66 ComponentPatcherCrossPlatform(); 68 ComponentPatcherCrossPlatform();
67 virtual ComponentUnpacker::Error Patch(PatchType patch_type, 69 virtual ComponentUnpacker::Error Patch(
68 const base::FilePath& input_file, 70 PatchType patch_type,
69 const base::FilePath& patch_file, 71 const base::FilePath& input_file,
70 const base::FilePath& output_file, 72 const base::FilePath& patch_file,
71 int* error) OVERRIDE; 73 const base::FilePath& output_file,
74 int* error) OVERRIDE;
72 private: 75 private:
73 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); 76 DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform);
74 }; 77 };
75 78
76 // This function takes an unpacked differential CRX (|input_dir|) and a 79 // This function takes an unpacked differential CRX (|input_dir|) and a
77 // component installer, and creates a new (non-differential) unpacked CRX, which 80 // component installer, and creates a new (non-differential) unpacked CRX, which
78 // is then installed normally. 81 // is then installed normally.
79 // The non-differential files are written into the |unpack_dir| directory. 82 // The non-differential files are written into the |unpack_dir| directory.
80 // Sets |error| to the error code of the first failing patch operation. 83 // When finished, calls the callback, passing error codes if any errors were
81 ComponentUnpacker::Error DifferentialUpdatePatch( 84 // encountered.
85 void DifferentialUpdatePatch(
82 const base::FilePath& input_dir, 86 const base::FilePath& input_dir,
83 const base::FilePath& unpack_dir, 87 const base::FilePath& unpack_dir,
84 ComponentPatcher* component_patcher, 88 ComponentPatcher* component_patcher,
85 ComponentInstaller* installer, 89 ComponentInstaller* installer,
86 int* error); 90 base::Callback<void(ComponentUnpacker::Error, int)> callback);
87 91
88 } // namespace component_updater 92 } // namespace component_updater
89 93
90 #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