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

Side by Side Diff: components/update_client/component_patcher.h

Issue 897873002: Make ComponentInstaller refcounted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@2015_01_19_component_installer
Patch Set: fix Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Encapsulates a task for applying a differential update to a component. 54 // Encapsulates a task for applying a differential update to a component.
55 class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> { 55 class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> {
56 public: 56 public:
57 // Takes an unpacked differential CRX (|input_dir|) and a component installer, 57 // Takes an unpacked differential CRX (|input_dir|) and a component installer,
58 // and sets up the class to create a new (non-differential) unpacked CRX. 58 // and sets up the class to create a new (non-differential) unpacked CRX.
59 // If |in_process| is true, patching will be done completely within the 59 // If |in_process| is true, patching will be done completely within the
60 // existing process. Otherwise, some steps of patching may be done 60 // existing process. Otherwise, some steps of patching may be done
61 // out-of-process. 61 // out-of-process.
62 ComponentPatcher(const base::FilePath& input_dir, 62 ComponentPatcher(const base::FilePath& input_dir,
63 const base::FilePath& unpack_dir, 63 const base::FilePath& unpack_dir,
64 ComponentInstaller* installer, 64 scoped_refptr<ComponentInstaller> installer,
65 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher, 65 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher,
66 scoped_refptr<base::SequencedTaskRunner> task_runner); 66 scoped_refptr<base::SequencedTaskRunner> task_runner);
67 67
68 // Starts patching files. This member function returns immediately, after 68 // Starts patching files. This member function returns immediately, after
69 // posting a task to do the patching. When patching has been completed, 69 // posting a task to do the patching. When patching has been completed,
70 // |callback| will be called with the error codes if any error codes were 70 // |callback| will be called with the error codes if any error codes were
71 // encountered. 71 // encountered.
72 void Start(const ComponentUnpacker::Callback& callback); 72 void Start(const ComponentUnpacker::Callback& callback);
73 73
74 private: 74 private:
75 friend class base::RefCountedThreadSafe<ComponentPatcher>; 75 friend class base::RefCountedThreadSafe<ComponentPatcher>;
76 76
77 virtual ~ComponentPatcher(); 77 virtual ~ComponentPatcher();
78 78
79 void StartPatching(); 79 void StartPatching();
80 80
81 void PatchNextFile(); 81 void PatchNextFile();
82 82
83 void DonePatchingFile(ComponentUnpacker::Error error, int extended_error); 83 void DonePatchingFile(ComponentUnpacker::Error error, int extended_error);
84 84
85 void DonePatching(ComponentUnpacker::Error error, int extended_error); 85 void DonePatching(ComponentUnpacker::Error error, int extended_error);
86 86
87 const base::FilePath input_dir_; 87 const base::FilePath input_dir_;
88 const base::FilePath unpack_dir_; 88 const base::FilePath unpack_dir_;
89 ComponentInstaller* const installer_; 89 scoped_refptr<ComponentInstaller> installer_;
90 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_; 90 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_;
91 ComponentUnpacker::Callback callback_; 91 ComponentUnpacker::Callback callback_;
92 scoped_ptr<base::ListValue> commands_; 92 scoped_ptr<base::ListValue> commands_;
93 base::ValueVector::const_iterator next_command_; 93 base::ValueVector::const_iterator next_command_;
94 scoped_refptr<DeltaUpdateOp> current_operation_; 94 scoped_refptr<DeltaUpdateOp> current_operation_;
95 scoped_refptr<base::SequencedTaskRunner> task_runner_; 95 scoped_refptr<base::SequencedTaskRunner> task_runner_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(ComponentPatcher); 97 DISALLOW_COPY_AND_ASSIGN(ComponentPatcher);
98 }; 98 };
99 99
100 } // namespace update_client 100 } // namespace update_client
101 101
102 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_PATCHER_H_ 102 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_PATCHER_H_
OLDNEW
« no previous file with comments | « components/component_updater/default_component_installer.cc ('k') | components/update_client/component_patcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698