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

Side by Side Diff: components/component_updater/default_component_installer.h

Issue 1937683002: Implement support in DefaultComponentInstaller for picking up bundled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review. Created 4 years, 7 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 #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 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/files/file_path.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "base/version.h" 20 #include "base/version.h"
20 #include "components/update_client/update_client.h" 21 #include "components/update_client/update_client.h"
21 22
22 namespace base { 23 namespace base {
23 class FilePath;
24 class SequencedTaskRunner; 24 class SequencedTaskRunner;
25 class SingleThreadTaskRunner; 25 class SingleThreadTaskRunner;
26 } // namespace base 26 } // namespace base
27 27
28 namespace component_updater { 28 namespace component_updater {
29 29
30 class ComponentUpdateService; 30 class ComponentUpdateService;
31 31
32 // Components should use a DefaultComponentInstaller by defining a class that 32 // Components should use a DefaultComponentInstaller by defining a class that
33 // implements the members of ComponentInstallerTraits, and then registering a 33 // implements the members of ComponentInstallerTraits, and then registering a
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // notified of a successful install, and is meant to support follow-on work 69 // notified of a successful install, and is meant to support follow-on work
70 // such as updating paths elsewhere in Chrome. Called on the UI thread. 70 // such as updating paths elsewhere in Chrome. Called on the UI thread.
71 // |version| is the version of the component. 71 // |version| is the version of the component.
72 // |install_dir| is the path to the install directory for this version. 72 // |install_dir| is the path to the install directory for this version.
73 // |manifest| is the manifest for this version of the component. 73 // |manifest| is the manifest for this version of the component.
74 virtual void ComponentReady( 74 virtual void ComponentReady(
75 const base::Version& version, 75 const base::Version& version,
76 const base::FilePath& install_dir, 76 const base::FilePath& install_dir,
77 std::unique_ptr<base::DictionaryValue> manifest) = 0; 77 std::unique_ptr<base::DictionaryValue> manifest) = 0;
78 78
79 // Returns the directory that the installer will place versioned installs of 79 // Returns a filesystem-safe name that will be used as the directory name for
80 // the component into. 80 // the component's contents.
81 virtual base::FilePath GetBaseDirectory() const = 0; 81 virtual std::string GetASCIIDirectoryName() const = 0;
xhwang 2016/05/02 17:47:00 What's the reason that we have to use ASCII dir na
Sorin Jianu 2016/05/03 00:04:43 A more descriptive name would be desired, not sure
waffles 2016/05/03 21:04:22 Clarified that this should be a relative path, cha
waffles 2016/05/03 21:04:23 Changed the name.
82 82
83 // Returns the component's SHA2 hash as raw bytes. 83 // Returns the component's SHA2 hash as raw bytes.
84 virtual void GetHash(std::vector<uint8_t>* hash) const = 0; 84 virtual void GetHash(std::vector<uint8_t>* hash) const = 0;
85 85
86 // Returns the human-readable name of the component. 86 // Returns the human-readable name of the component.
87 virtual std::string GetName() const = 0; 87 virtual std::string GetName() const = 0;
88 88
89 // Returns the additional parameters to be used in the update checks for 89 // Returns the additional parameters to be used in the update checks for
90 // this component. A compatible server may use this attribute to negotiate 90 // this component. A compatible server may use this attribute to negotiate
91 // special update rules when issuing an update response. 91 // special update rules when issuing an update response.
(...skipping 13 matching lines...) Expand all
105 // The passed |callback| will be called once the initial check for installed 105 // The passed |callback| will be called once the initial check for installed
106 // versions is done and the component has been registered. 106 // versions is done and the component has been registered.
107 void Register(ComponentUpdateService* cus, const base::Closure& callback); 107 void Register(ComponentUpdateService* cus, const base::Closure& callback);
108 108
109 // Overridden from ComponentInstaller: 109 // Overridden from ComponentInstaller:
110 void OnUpdateError(int error) override; 110 void OnUpdateError(int error) override;
111 bool Install(const base::DictionaryValue& manifest, 111 bool Install(const base::DictionaryValue& manifest,
112 const base::FilePath& unpack_path) override; 112 const base::FilePath& unpack_path) override;
113 bool GetInstalledFile(const std::string& file, 113 bool GetInstalledFile(const std::string& file,
114 base::FilePath* installed_file) override; 114 base::FilePath* installed_file) override;
115 // Only user-level component installations can be uninstalled.
115 bool Uninstall() override; 116 bool Uninstall() override;
116 117
117 private: 118 private:
118 ~DefaultComponentInstaller() override; 119 ~DefaultComponentInstaller() override;
119 120
120 base::FilePath GetInstallDirectory();
121 bool InstallHelper(const base::DictionaryValue& manifest, 121 bool InstallHelper(const base::DictionaryValue& manifest,
122 const base::FilePath& unpack_path, 122 const base::FilePath& unpack_path,
123 const base::FilePath& install_path); 123 const base::FilePath& install_path);
124 void StartRegistration(ComponentUpdateService* cus); 124 void StartRegistration(ComponentUpdateService* cus);
125 void FinishRegistration(ComponentUpdateService* cus, 125 void FinishRegistration(ComponentUpdateService* cus,
126 const base::Closure& callback); 126 const base::Closure& callback);
127 void ComponentReady(std::unique_ptr<base::DictionaryValue> manifest); 127 void ComponentReady(std::unique_ptr<base::DictionaryValue> manifest);
128 void UninstallOnTaskRunner(); 128 void UninstallOnTaskRunner();
129 129
130 base::FilePath current_install_dir_;
130 base::Version current_version_; 131 base::Version current_version_;
131 std::string current_fingerprint_; 132 std::string current_fingerprint_;
132 std::unique_ptr<base::DictionaryValue> current_manifest_; 133 std::unique_ptr<base::DictionaryValue> current_manifest_;
133 std::unique_ptr<ComponentInstallerTraits> installer_traits_; 134 std::unique_ptr<ComponentInstallerTraits> installer_traits_;
134 scoped_refptr<base::SequencedTaskRunner> task_runner_; 135 scoped_refptr<base::SequencedTaskRunner> task_runner_;
135 136
136 // Used to post responses back to the main thread. Initialized on the main 137 // Used to post responses back to the main thread. Initialized on the main
137 // loop but accessed from the task runner. 138 // loop but accessed from the task runner.
138 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 139 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
139 140
140 base::ThreadChecker thread_checker_; 141 base::ThreadChecker thread_checker_;
141 142
142 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller); 143 DISALLOW_COPY_AND_ASSIGN(DefaultComponentInstaller);
143 }; 144 };
144 145
145 } // namespace component_updater 146 } // namespace component_updater
146 147
147 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_ 148 #endif // COMPONENTS_COMPONENT_UPDATER_DEFAULT_COMPONENT_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698