Chromium Code Reviews| Index: chrome/browser/component_updater/component_patcher.h |
| diff --git a/chrome/browser/component_updater/component_patcher.h b/chrome/browser/component_updater/component_patcher.h |
| index 6a6cb8f084cbaee4127adeed43b6b52742a8e141..dc58dca334328ab6ede8be13658bf8332fe40f52 100644 |
| --- a/chrome/browser/component_updater/component_patcher.h |
| +++ b/chrome/browser/component_updater/component_patcher.h |
| @@ -28,9 +28,7 @@ |
| #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
| #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
| -#include "base/basictypes.h" |
| #include "base/callback_forward.h" |
| -#include "base/compiler_specific.h" |
| #include "chrome/browser/component_updater/component_unpacker.h" |
| namespace base { |
| @@ -40,52 +38,58 @@ class FilePath; |
| namespace component_updater { |
| class ComponentInstaller; |
| +class DeltaUpdateOp; |
| -// Applies a delta patch to a single file. Specifically, creates a file at |
| -// |output_file| using |input_file| patched according to the algorithm |
| -// specified by |patch_type| using |patch_file|. Sets the value of error to |
| -// the error code of the failing patch operation, if there is such a failure. |
| -class ComponentPatcher { |
| - public: |
| - // The type of a patch file. |
| - enum PatchType { |
| - kPatchTypeUnknown, |
| - kPatchTypeCourgette, |
| - kPatchTypeBsdiff, |
| - }; |
| - |
| - virtual ComponentUnpacker::Error Patch(PatchType patch_type, |
| - const base::FilePath& input_file, |
| - const base::FilePath& patch_file, |
| - const base::FilePath& output_file, |
| - int* error) = 0; |
| - virtual ~ComponentPatcher() {} |
| +// The type of a patch file. |
| +enum PatchType { |
| + kPatchTypeUnknown, |
| + kPatchTypeCourgette, |
| + kPatchTypeBsdiff, |
| }; |
| -class ComponentPatcherCrossPlatform : public ComponentPatcher { |
| +// Applies a delta patch to a set of files. |
| +// The constructor takes an unpacked differential CRX (|input_dir|) and a |
|
Sorin Jianu
2014/02/03 20:57:57
This comment appears to be a function comment inst
waffles
2014/02/07 01:00:59
Done.
|
| +// component installer, and sets up the class to create a new (non-differential) |
| +// unpacked CRX. |
| +// The non-differential files are written into the |unpack_dir| directory. |
| +// When finished, calls |callback|, passing error codes if any errors were |
| +// encountered. |
|
Sorin Jianu
2014/02/03 20:57:57
Calls |callback| when finished, with the error cod
waffles
2014/02/07 01:00:59
Done.
|
| +class ComponentPatcher { |
| public: |
| - ComponentPatcherCrossPlatform(); |
| - virtual ComponentUnpacker::Error Patch(PatchType patch_type, |
| - const base::FilePath& input_file, |
| - const base::FilePath& patch_file, |
| - const base::FilePath& output_file, |
| - int* error) OVERRIDE; |
| + ComponentPatcher(const base::FilePath& input_dir, |
| + const base::FilePath& unpack_dir, |
| + ComponentInstaller* installer, |
| + bool in_process, |
|
Sorin Jianu
2014/02/03 20:57:57
might want to document |in_process|.
waffles
2014/02/07 01:00:59
Done.
|
| + scoped_refptr<base::SequencedTaskRunner> task_runner); |
| + |
| + virtual ~ComponentPatcher(); |
| + |
| + // Starts patching files. This method returns immediately, after posting a |
|
Sorin Jianu
2014/02/03 20:57:57
Technically, in C++ only virtual member functions
waffles
2014/02/07 01:00:59
Could you provide me with a reference on this? All
Sorin Jianu
2014/02/27 20:53:57
http://books.google.com/books?id=0klsAQAAQBAJ&prin
|
| + // task to do the patching. |
| + void Start( |
| + const base::Callback<void(ComponentUnpacker::Error, int)>& callback); |
| + |
| + // Returns a weak pointer to this object. |
| + base::WeakPtr<ComponentPatcher> GetWeakPtr(); |
| + |
| private: |
| - DISALLOW_COPY_AND_ASSIGN(ComponentPatcherCrossPlatform); |
| -}; |
| + void PatchNextFile(); |
| -// This function takes an unpacked differential CRX (|input_dir|) and a |
| -// component installer, and creates a new (non-differential) unpacked CRX, which |
| -// is then installed normally. |
| -// The non-differential files are written into the |unpack_dir| directory. |
| -// When finished, calls the callback, passing error codes if any errors were |
| -// encountered. |
| -void DifferentialUpdatePatch( |
| - const base::FilePath& input_dir, |
| - const base::FilePath& unpack_dir, |
| - ComponentPatcher* component_patcher, |
| - ComponentInstaller* installer, |
| - base::Callback<void(ComponentUnpacker::Error, int)> callback); |
| + void DonePatchingFile(ComponentUnpacker::Error error, int extended_error); |
| + |
| + base::FilePath input_dir_; |
|
Sorin Jianu
2014/02/03 20:57:57
Can some of these members be declared const? The o
waffles
2014/02/07 01:00:59
Done.
|
| + base::FilePath unpack_dir_; |
| + ComponentInstaller* installer_; |
| + bool in_process_; |
| + base::Callback<void(ComponentUnpacker::Error, int)> callback_; |
| + scoped_ptr<base::ListValue> commands_; |
| + base::ValueVector::const_iterator next_command_; |
| + scoped_ptr<DeltaUpdateOp> current_operation_; |
| + base::WeakPtrFactory<ComponentPatcher> ptr_factory_; |
| + scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ComponentPatcher); |
| +}; |
| } // namespace component_updater |