OLD | NEW |
---|---|
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 22 matching lines...) Expand all Loading... | |
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 namespace component_updater { | 39 namespace component_updater { |
40 | 40 |
41 class ComponentInstaller; | 41 class ComponentInstaller; |
42 class DeltaUpdateOp; | 42 class DeltaUpdateOp; |
43 class DeltaUpdateOpFactory; | |
43 | 44 |
44 // The type of a patch file. | 45 // The type of a patch file. |
45 enum PatchType { | 46 enum PatchType { |
46 kPatchTypeUnknown, | 47 kPatchTypeUnknown, |
47 kPatchTypeCourgette, | 48 kPatchTypeCourgette, |
48 kPatchTypeBsdiff, | 49 kPatchTypeBsdiff, |
49 }; | 50 }; |
50 | 51 |
51 // Encapsulates a task for applying a differential update to a component. | 52 // Encapsulates a task for applying a differential update to a component. |
52 class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> { | 53 class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> { |
53 public: | 54 public: |
54 // Takes an unpacked differential CRX (|input_dir|) and a component installer, | 55 // Takes an unpacked differential CRX (|input_dir|) and a component installer, |
55 // and sets up the class to create a new (non-differential) unpacked CRX. | 56 // and sets up the class to create a new (non-differential) unpacked CRX. |
56 // If |in_process| is true, patching will be done completely within the | 57 // If |in_process| is true, patching will be done completely within the |
57 // existing process. Otherwise, some steps of patching may be done | 58 // existing process. Otherwise, some steps of patching may be done |
58 // out-of-process. | 59 // out-of-process. |
59 ComponentPatcher(const base::FilePath& input_dir, | 60 ComponentPatcher(const base::FilePath& input_dir, |
60 const base::FilePath& unpack_dir, | 61 const base::FilePath& unpack_dir, |
61 ComponentInstaller* installer, | 62 ComponentInstaller* installer, |
62 bool in_process, | 63 DeltaUpdateOpFactory* delta_update_op_factory, |
blundell
2014/07/25 07:40:42
If this object takes ownership of the factory, it
tommycli
2014/07/25 18:08:47
I changed all the usages of this class to use scop
| |
63 scoped_refptr<base::SequencedTaskRunner> task_runner); | 64 scoped_refptr<base::SequencedTaskRunner> task_runner); |
64 | 65 |
65 // Starts patching files. This member function returns immediately, after | 66 // Starts patching files. This member function returns immediately, after |
66 // posting a task to do the patching. When patching has been completed, | 67 // posting a task to do the patching. When patching has been completed, |
67 // |callback| will be called with the error codes if any error codes were | 68 // |callback| will be called with the error codes if any error codes were |
68 // encountered. | 69 // encountered. |
69 void Start(const ComponentUnpacker::Callback& callback); | 70 void Start(const ComponentUnpacker::Callback& callback); |
70 | 71 |
71 private: | 72 private: |
72 friend class base::RefCountedThreadSafe<ComponentPatcher>; | 73 friend class base::RefCountedThreadSafe<ComponentPatcher>; |
73 | 74 |
74 virtual ~ComponentPatcher(); | 75 virtual ~ComponentPatcher(); |
75 | 76 |
76 void StartPatching(); | 77 void StartPatching(); |
77 | 78 |
78 void PatchNextFile(); | 79 void PatchNextFile(); |
79 | 80 |
80 void DonePatchingFile(ComponentUnpacker::Error error, int extended_error); | 81 void DonePatchingFile(ComponentUnpacker::Error error, int extended_error); |
81 | 82 |
82 void DonePatching(ComponentUnpacker::Error error, int extended_error); | 83 void DonePatching(ComponentUnpacker::Error error, int extended_error); |
83 | 84 |
84 const base::FilePath input_dir_; | 85 const base::FilePath input_dir_; |
85 const base::FilePath unpack_dir_; | 86 const base::FilePath unpack_dir_; |
86 ComponentInstaller* const installer_; | 87 ComponentInstaller* const installer_; |
87 const bool in_process_; | 88 scoped_ptr<DeltaUpdateOpFactory> delta_update_op_factory_; |
88 ComponentUnpacker::Callback callback_; | 89 ComponentUnpacker::Callback callback_; |
89 scoped_ptr<base::ListValue> commands_; | 90 scoped_ptr<base::ListValue> commands_; |
90 base::ValueVector::const_iterator next_command_; | 91 base::ValueVector::const_iterator next_command_; |
91 scoped_refptr<DeltaUpdateOp> current_operation_; | 92 scoped_refptr<DeltaUpdateOp> current_operation_; |
92 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 93 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(ComponentPatcher); | 95 DISALLOW_COPY_AND_ASSIGN(ComponentPatcher); |
95 }; | 96 }; |
96 | 97 |
97 } // namespace component_updater | 98 } // namespace component_updater |
98 | 99 |
99 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ | 100 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_PATCHER_H_ |
OLD | NEW |