| 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 |
| 102 private: | 106 private: |
| 103 ~DefaultComponentInstaller() override; | 107 ~DefaultComponentInstaller() override; |
| 104 | 108 |
| 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 void ComponentReady(scoped_ptr<base::DictionaryValue> manifest); | 115 void ComponentReady(scoped_ptr<base::DictionaryValue> manifest); |
| 112 | 116 |
| 113 base::Version current_version_; | 117 base::Version current_version_; |
| 114 std::string current_fingerprint_; | 118 std::string current_fingerprint_; |
| 115 scoped_ptr<base::DictionaryValue> current_manifest_; | 119 scoped_ptr<base::DictionaryValue> current_manifest_; |
| 116 scoped_ptr<ComponentInstallerTraits> installer_traits_; | 120 scoped_ptr<ComponentInstallerTraits> installer_traits_; |
| 117 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 121 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 122 bool should_uninstall_on_destruction_; |
| 118 | 123 |
| 119 // Used to post responses back to the main thread. Initialized on the main | 124 // Used to post responses back to the main thread. Initialized on the main |
| 120 // loop but accessed from the task runner. | 125 // loop but accessed from the task runner. |
| 121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 126 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 122 | 127 |
| 123 base::ThreadChecker thread_checker_; | 128 base::ThreadChecker thread_checker_; |
| 124 | 129 |
| 125 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); | 130 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); |
| 126 }; | 131 }; |
| 127 | 132 |
| 128 } // namespace component_updater | 133 } // namespace component_updater |
| 129 | 134 |
| 130 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 135 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| OLD | NEW |