OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/component_updater/sth_set_component_installer.h" | 5 #include "chrome/browser/component_updater/sth_set_component_installer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 bool STHSetComponentInstallerTraits::OnCustomInstall( | 67 bool STHSetComponentInstallerTraits::OnCustomInstall( |
68 const base::DictionaryValue& manifest, | 68 const base::DictionaryValue& manifest, |
69 const base::FilePath& install_dir) { | 69 const base::FilePath& install_dir) { |
70 return true; // Nothing custom here. | 70 return true; // Nothing custom here. |
71 } | 71 } |
72 | 72 |
73 void STHSetComponentInstallerTraits::ComponentReady( | 73 void STHSetComponentInstallerTraits::ComponentReady( |
74 const base::Version& version, | 74 const base::Version& version, |
75 const base::FilePath& install_dir, | 75 const base::FilePath& install_dir, |
76 std::unique_ptr<base::DictionaryValue> manifest) { | 76 std::unique_ptr<base::DictionaryValue> manifest) { |
77 if (!content::BrowserThread::PostBlockingPoolTask( | 77 content::BrowserThread::PostAfterStartupTask( |
Alexei Svitkine (slow)
2016/07/12 14:56:09
Per comment on the bug, please keep the old behavi
Eran Messeri
2016/07/12 16:14:42
Done.
| |
78 FROM_HERE, | 78 FROM_HERE, content::BrowserThread::GetBlockingPool(), |
79 base::Bind(&STHSetComponentInstallerTraits::LoadSTHsFromDisk, | 79 base::Bind(&STHSetComponentInstallerTraits::PostStartupLoadSTHsFromDisk, |
waffles
2016/07/12 13:56:59
Why not directly post LoadSTHsFromDisk? (I'm not s
Eran Messeri
2016/07/12 16:14:42
No reason really, removed.
| |
80 base::Unretained(this), GetInstalledPath(install_dir), | 80 base::Unretained(this), install_dir, version)); |
81 version))) { | |
82 NOTREACHED(); | |
83 } | |
84 } | 81 } |
85 | 82 |
86 // Called during startup and installation before ComponentReady(). | 83 // Called during startup and installation before ComponentReady(). |
87 bool STHSetComponentInstallerTraits::VerifyInstallation( | 84 bool STHSetComponentInstallerTraits::VerifyInstallation( |
88 const base::DictionaryValue& manifest, | 85 const base::DictionaryValue& manifest, |
89 const base::FilePath& install_dir) const { | 86 const base::FilePath& install_dir) const { |
90 return base::PathExists(GetInstalledPath(install_dir)); | 87 return base::PathExists(GetInstalledPath(install_dir)); |
91 } | 88 } |
92 | 89 |
93 base::FilePath STHSetComponentInstallerTraits::GetRelativeInstallDir() const { | 90 base::FilePath STHSetComponentInstallerTraits::GetRelativeInstallDir() const { |
94 return base::FilePath(FILE_PATH_LITERAL("CertificateTransparency")); | 91 return base::FilePath(FILE_PATH_LITERAL("CertificateTransparency")); |
95 } | 92 } |
96 | 93 |
97 void STHSetComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const { | 94 void STHSetComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const { |
98 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256)); | 95 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256)); |
99 } | 96 } |
100 | 97 |
101 std::string STHSetComponentInstallerTraits::GetName() const { | 98 std::string STHSetComponentInstallerTraits::GetName() const { |
102 return kSTHSetFetcherManifestName; | 99 return kSTHSetFetcherManifestName; |
103 } | 100 } |
104 | 101 |
105 update_client::InstallerAttributes | 102 update_client::InstallerAttributes |
106 STHSetComponentInstallerTraits::GetInstallerAttributes() const { | 103 STHSetComponentInstallerTraits::GetInstallerAttributes() const { |
107 return update_client::InstallerAttributes(); | 104 return update_client::InstallerAttributes(); |
108 } | 105 } |
109 | 106 |
107 void STHSetComponentInstallerTraits::PostStartupLoadSTHsFromDisk( | |
108 const base::FilePath& install_dir, | |
109 const base::Version& version) { | |
110 if (!content::BrowserThread::PostBlockingPoolTask( | |
111 FROM_HERE, | |
112 base::Bind(&STHSetComponentInstallerTraits::LoadSTHsFromDisk, | |
113 base::Unretained(this), GetInstalledPath(install_dir), | |
114 version))) { | |
115 NOTREACHED(); | |
116 } | |
117 } | |
118 | |
110 void STHSetComponentInstallerTraits::LoadSTHsFromDisk( | 119 void STHSetComponentInstallerTraits::LoadSTHsFromDisk( |
111 const base::FilePath& sths_path, | 120 const base::FilePath& sths_path, |
112 const base::Version& version) { | 121 const base::Version& version) { |
113 if (sths_path.empty()) | 122 if (sths_path.empty()) |
114 return; | 123 return; |
115 | 124 |
116 base::FileEnumerator sth_file_enumerator(sths_path, false, | 125 base::FileEnumerator sth_file_enumerator(sths_path, false, |
117 base::FileEnumerator::FILES, | 126 base::FileEnumerator::FILES, |
118 FILE_PATH_LITERAL("*.sth")); | 127 FILE_PATH_LITERAL("*.sth")); |
119 base::FilePath sth_file_path; | 128 base::FilePath sth_file_path; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 200 |
192 std::unique_ptr<ComponentInstallerTraits> traits( | 201 std::unique_ptr<ComponentInstallerTraits> traits( |
193 new STHSetComponentInstallerTraits(distributor)); | 202 new STHSetComponentInstallerTraits(distributor)); |
194 // |cus| will take ownership of |installer| during installer->Register(cus). | 203 // |cus| will take ownership of |installer| during installer->Register(cus). |
195 DefaultComponentInstaller* installer = | 204 DefaultComponentInstaller* installer = |
196 new DefaultComponentInstaller(std::move(traits)); | 205 new DefaultComponentInstaller(std::move(traits)); |
197 installer->Register(cus, base::Closure()); | 206 installer->Register(cus, base::Closure()); |
198 } | 207 } |
199 | 208 |
200 } // namespace component_updater | 209 } // namespace component_updater |
OLD | NEW |