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" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "base/version.h" | 17 #include "base/version.h" |
18 #include "chrome/browser/net/sth_distributor_provider.h" | 18 #include "chrome/browser/net/sth_distributor_provider.h" |
19 #include "chrome/common/chrome_features.h" | |
19 #include "components/component_updater/component_updater_paths.h" | 20 #include "components/component_updater/component_updater_paths.h" |
20 #include "components/safe_json/safe_json_parser.h" | 21 #include "components/safe_json/safe_json_parser.h" |
22 #include "components/variations/variations_associated_data.h" | |
21 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
22 #include "crypto/sha2.h" | 24 #include "crypto/sha2.h" |
23 #include "net/cert/ct_log_response_parser.h" | 25 #include "net/cert/ct_log_response_parser.h" |
24 #include "net/cert/signed_tree_head.h" | 26 #include "net/cert/signed_tree_head.h" |
25 #include "net/cert/sth_distributor.h" | 27 #include "net/cert/sth_distributor.h" |
26 #include "net/cert/sth_observer.h" | 28 #include "net/cert/sth_observer.h" |
27 | 29 |
28 using component_updater::ComponentUpdateService; | 30 using component_updater::ComponentUpdateService; |
29 | 31 |
30 namespace { | 32 namespace { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 bool STHSetComponentInstallerTraits::OnCustomInstall( | 69 bool STHSetComponentInstallerTraits::OnCustomInstall( |
68 const base::DictionaryValue& manifest, | 70 const base::DictionaryValue& manifest, |
69 const base::FilePath& install_dir) { | 71 const base::FilePath& install_dir) { |
70 return true; // Nothing custom here. | 72 return true; // Nothing custom here. |
71 } | 73 } |
72 | 74 |
73 void STHSetComponentInstallerTraits::ComponentReady( | 75 void STHSetComponentInstallerTraits::ComponentReady( |
74 const base::Version& version, | 76 const base::Version& version, |
75 const base::FilePath& install_dir, | 77 const base::FilePath& install_dir, |
76 std::unique_ptr<base::DictionaryValue> manifest) { | 78 std::unique_ptr<base::DictionaryValue> manifest) { |
77 if (!content::BrowserThread::PostBlockingPoolTask( | 79 if (variations::GetVariationParamValueByFeature(features::kSTHSetComponent, |
78 FROM_HERE, | 80 "delayed_load") == "yes") { |
gab
2016/07/12 20:09:25
Flip this condition around (i.e. make the default
Eran Messeri
2016/07/13 10:51:55
Done.
| |
79 base::Bind(&STHSetComponentInstallerTraits::LoadSTHsFromDisk, | 81 content::BrowserThread::PostAfterStartupTask( |
gab
2016/07/12 20:09:24
Actually, IIUC from https://codereview.chromium.or
Eran Messeri
2016/07/13 10:51:55
Yes, loading the STHs can be delayed by 5-10 minut
gab
2016/07/13 17:29:08
Ok then please use:
// STHs perform an async sani
gab
2016/07/14 14:46:03
ping (shall we do a mega delay? that won't result
Eran Messeri
2016/07/18 09:36:06
To follow up, since we came to the conclusion we c
| |
80 base::Unretained(this), GetInstalledPath(install_dir), | 82 FROM_HERE, content::BrowserThread::GetBlockingPool(), |
81 version))) { | 83 base::Bind(&STHSetComponentInstallerTraits::LoadSTHsFromDisk, |
82 NOTREACHED(); | 84 base::Unretained(this), GetInstalledPath(install_dir), |
Alexei Svitkine (slow)
2016/07/12 19:59:27
As an aside, why is this used base::Unretained()?
Eran Messeri
2016/07/13 10:51:55
There are no guarantees, so I've switched to a Wea
| |
85 version)); | |
86 } else { | |
87 if (!content::BrowserThread::PostBlockingPoolTask( | |
88 FROM_HERE, | |
89 base::Bind(&STHSetComponentInstallerTraits::LoadSTHsFromDisk, | |
gab
2016/07/12 20:09:24
Extract:
const base::Closure load_sths_closure =
Eran Messeri
2016/07/13 10:51:55
Done.
| |
90 base::Unretained(this), GetInstalledPath(install_dir), | |
91 version))) { | |
92 NOTREACHED(); | |
gab
2016/07/12 20:09:24
This NOTREACHED() is not necessary. PostTask() wil
Eran Messeri
2016/07/13 10:51:55
Thanks for the explanation, removed. Does it make
gab
2016/07/13 17:29:08
There are far more places that don't have NOTREACH
| |
93 } | |
83 } | 94 } |
84 } | 95 } |
85 | 96 |
86 // Called during startup and installation before ComponentReady(). | 97 // Called during startup and installation before ComponentReady(). |
87 bool STHSetComponentInstallerTraits::VerifyInstallation( | 98 bool STHSetComponentInstallerTraits::VerifyInstallation( |
88 const base::DictionaryValue& manifest, | 99 const base::DictionaryValue& manifest, |
89 const base::FilePath& install_dir) const { | 100 const base::FilePath& install_dir) const { |
90 return base::PathExists(GetInstalledPath(install_dir)); | 101 return base::PathExists(GetInstalledPath(install_dir)); |
91 } | 102 } |
92 | 103 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 202 |
192 std::unique_ptr<ComponentInstallerTraits> traits( | 203 std::unique_ptr<ComponentInstallerTraits> traits( |
193 new STHSetComponentInstallerTraits(distributor)); | 204 new STHSetComponentInstallerTraits(distributor)); |
194 // |cus| will take ownership of |installer| during installer->Register(cus). | 205 // |cus| will take ownership of |installer| during installer->Register(cus). |
195 DefaultComponentInstaller* installer = | 206 DefaultComponentInstaller* installer = |
196 new DefaultComponentInstaller(std::move(traits)); | 207 new DefaultComponentInstaller(std::move(traits)); |
197 installer->Register(cus, base::Closure()); | 208 installer->Register(cus, base::Closure()); |
198 } | 209 } |
199 | 210 |
200 } // namespace component_updater | 211 } // namespace component_updater |
OLD | NEW |