OLD | NEW |
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 #ifndef COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Customization must be provided by passing a ComponentInstallerTraits object | 85 // Customization must be provided by passing a ComponentInstallerTraits object |
86 // to the constructor. | 86 // to the constructor. |
87 class DefaultComponentInstaller : public update_client::ComponentInstaller { | 87 class DefaultComponentInstaller : public update_client::ComponentInstaller { |
88 public: | 88 public: |
89 DefaultComponentInstaller( | 89 DefaultComponentInstaller( |
90 scoped_ptr<ComponentInstallerTraits> installer_traits); | 90 scoped_ptr<ComponentInstallerTraits> installer_traits); |
91 | 91 |
92 // Registers the component for update checks and installs. | 92 // Registers the component for update checks and installs. |
93 void Register(ComponentUpdateService* cus); | 93 void Register(ComponentUpdateService* cus); |
94 | 94 |
| 95 // Unregisters the component for update checks and uninstalls it when the last |
| 96 // reference to it is dropped. |
| 97 void Unregister(ComponentUpdateService* cus); |
| 98 |
95 // Overridden from ComponentInstaller: | 99 // Overridden from ComponentInstaller: |
96 void OnUpdateError(int error) override; | 100 void OnUpdateError(int error) override; |
97 bool Install(const base::DictionaryValue& manifest, | 101 bool Install(const base::DictionaryValue& manifest, |
98 const base::FilePath& unpack_path) override; | 102 const base::FilePath& unpack_path) override; |
99 bool GetInstalledFile(const std::string& file, | 103 bool GetInstalledFile(const std::string& file, |
100 base::FilePath* installed_file) override; | 104 base::FilePath* installed_file) override; |
101 | 105 |
| 106 private: |
102 ~DefaultComponentInstaller() override; | 107 ~DefaultComponentInstaller() override; |
103 | 108 |
104 private: | |
105 base::FilePath GetInstallDirectory(); | 109 base::FilePath GetInstallDirectory(); |
106 bool InstallHelper(const base::DictionaryValue& manifest, | 110 bool InstallHelper(const base::DictionaryValue& manifest, |
107 const base::FilePath& unpack_path, | 111 const base::FilePath& unpack_path, |
108 const base::FilePath& install_path); | 112 const base::FilePath& install_path); |
109 void StartRegistration(ComponentUpdateService* cus); | 113 void StartRegistration(ComponentUpdateService* cus); |
110 void FinishRegistration(ComponentUpdateService* cus); | 114 void FinishRegistration(ComponentUpdateService* cus); |
111 | 115 |
112 base::Version current_version_; | 116 base::Version current_version_; |
113 std::string current_fingerprint_; | 117 std::string current_fingerprint_; |
114 scoped_ptr<base::DictionaryValue> current_manifest_; | 118 scoped_ptr<base::DictionaryValue> current_manifest_; |
115 scoped_ptr<ComponentInstallerTraits> installer_traits_; | 119 scoped_ptr<ComponentInstallerTraits> installer_traits_; |
116 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 120 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 121 bool should_uninstall_on_destruction_; |
117 | 122 |
118 // Used to post responses back to the main thread. Initialized on the main | 123 // Used to post responses back to the main thread. Initialized on the main |
119 // loop but accessed from the task runner. | 124 // loop but accessed from the task runner. |
120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 125 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
121 | 126 |
122 base::ThreadChecker thread_checker_; | 127 base::ThreadChecker thread_checker_; |
123 | 128 |
124 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); | 129 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); |
125 }; | 130 }; |
126 | 131 |
127 } // namespace component_updater | 132 } // namespace component_updater |
128 | 133 |
129 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 134 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
OLD | NEW |