| 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> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "base/version.h" | 18 #include "base/version.h" |
| 19 #include "components/component_updater/component_updater_service.h" | 19 #include "components/update_client/update_client.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class FilePath; | 22 class FilePath; |
| 23 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
| 24 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 25 } // namespace base | 25 } // namespace base |
| 26 | 26 |
| 27 namespace component_updater { | 27 namespace component_updater { |
| 28 | 28 |
| 29 class ComponentUpdateService; |
| 30 |
| 29 // Components should use a DefaultComponentInstaller by defining a class that | 31 // Components should use a DefaultComponentInstaller by defining a class that |
| 30 // implements the members of ComponentInstallerTraits, and then registering a | 32 // implements the members of ComponentInstallerTraits, and then registering a |
| 31 // DefaultComponentInstaller that has been constructed with an instance of that | 33 // DefaultComponentInstaller that has been constructed with an instance of that |
| 32 // class. | 34 // class. |
| 33 class ComponentInstallerTraits { | 35 class ComponentInstallerTraits { |
| 34 public: | 36 public: |
| 35 virtual ~ComponentInstallerTraits(); | 37 virtual ~ComponentInstallerTraits(); |
| 36 | 38 |
| 37 // Verifies that a working installation resides within the directory specified | 39 // Verifies that a working installation resides within the directory specified |
| 38 // by |install_dir|. |install_dir| is of the form <base directory>/<version>. | 40 // by |install_dir|. |install_dir| is of the form <base directory>/<version>. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Returns the component's SHA2 hash as raw bytes. | 77 // Returns the component's SHA2 hash as raw bytes. |
| 76 virtual void GetHash(std::vector<uint8_t>* hash) const = 0; | 78 virtual void GetHash(std::vector<uint8_t>* hash) const = 0; |
| 77 | 79 |
| 78 // Returns the human-readable name of the component. | 80 // Returns the human-readable name of the component. |
| 79 virtual std::string GetName() const = 0; | 81 virtual std::string GetName() const = 0; |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 // A DefaultComponentInstaller is intended to be final, and not derived from. | 84 // A DefaultComponentInstaller is intended to be final, and not derived from. |
| 83 // Customization must be provided by passing a ComponentInstallerTraits object | 85 // Customization must be provided by passing a ComponentInstallerTraits object |
| 84 // to the constructor. | 86 // to the constructor. |
| 85 class DefaultComponentInstaller : public ComponentInstaller { | 87 class DefaultComponentInstaller : public update_client::ComponentInstaller { |
| 86 public: | 88 public: |
| 87 DefaultComponentInstaller( | 89 DefaultComponentInstaller( |
| 88 scoped_ptr<ComponentInstallerTraits> installer_traits); | 90 scoped_ptr<ComponentInstallerTraits> installer_traits); |
| 89 | 91 |
| 90 // Registers the component for update checks and installs. | 92 // Registers the component for update checks and installs. |
| 91 void Register(ComponentUpdateService* cus); | 93 void Register(ComponentUpdateService* cus); |
| 92 | 94 |
| 93 // Overridden from ComponentInstaller: | 95 // Overridden from ComponentInstaller: |
| 94 void OnUpdateError(int error) override; | 96 void OnUpdateError(int error) override; |
| 95 bool Install(const base::DictionaryValue& manifest, | 97 bool Install(const base::DictionaryValue& manifest, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 118 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 119 | 121 |
| 120 base::ThreadChecker thread_checker_; | 122 base::ThreadChecker thread_checker_; |
| 121 | 123 |
| 122 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); | 124 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); |
| 123 }; | 125 }; |
| 124 | 126 |
| 125 } // namespace component_updater | 127 } // namespace component_updater |
| 126 | 128 |
| 127 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ | 129 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ |
| OLD | NEW |