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

Side by Side Diff: chrome/browser/component_updater/sth_set_component_installer.h

Issue 1853753003: Certificate Transparency: New component for obtaining fresh STHs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ryan's comments, STHDistributor moved Created 4 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_
7
8 #include <stdint.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "components/component_updater/default_component_installer.h"
16
17 namespace base {
18 class FilePath;
19 class Value;
20 } // namespace base
21
22 namespace net {
23 namespace ct {
24 class STHObserver;
25 } // namespace ct
26 } // namespace net
27
28 namespace component_updater {
29
30 class ComponentUpdateService;
31
32 // Component for receiving Signed Tree Heads updates for Certificate
33 // Transparency logs recognized in Chrome.
34 // The STHs are in JSON format.
35 // To identify the log each STH belongs to, the name of the file is
36 // hex-encoded Log ID of the log that produced this STH.
37 //
38 // Instead, notifications of each of the new STHs are sent to the
waffles 2016/04/07 13:30:49 Instead of what? (Maybe just eliminate "instead".)
Eran Messeri 2016/04/07 16:37:59 Done.
39 // net::ct::STHObserver, so that it can take appropriate steps, including
40 // possible persistence.
41 class STHSetComponentInstallerTraits : public ComponentInstallerTraits {
42 public:
43 // The |sth_distributor| will be notified each time a new STH is observed.
44 explicit STHSetComponentInstallerTraits(
45 scoped_ptr<net::ct::STHObserver> sth_observer);
46 ~STHSetComponentInstallerTraits() override;
47
48 private:
49 friend class STHSetComponentInstallerTest;
50 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest, CanLoadAllSTHs);
51 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest,
52 DoesNotLoadInvalidJSON);
53 FRIEND_TEST_ALL_PREFIXES(STHSetComponentInstallerTest,
54 DoesNotLoadValidJSONFromFileNotHexEncoded);
55
56 // The following methods override ComponentInstallerTraits.
57 bool CanAutoUpdate() const override;
58 bool RequiresNetworkEncryption() const override;
59 bool OnCustomInstall(const base::DictionaryValue& manifest,
60 const base::FilePath& install_dir) override;
61 bool VerifyInstallation(const base::DictionaryValue& manifest,
62 const base::FilePath& install_dir) const override;
63 void ComponentReady(const base::Version& version,
64 const base::FilePath& install_dir,
65 scoped_ptr<base::DictionaryValue> manifest) override;
66 base::FilePath GetBaseDirectory() const override;
67 void GetHash(std::vector<uint8_t>* hash) const override;
68 std::string GetName() const override;
69
70 static base::FilePath GetInstalledPath(const base::FilePath& base);
71
72 // Reads and parses the on-disk json.
73 void LoadSTHsFromDisk(const base::FilePath& sths_file_path,
74 const base::Version& version);
75
76 // Handle successful parsing of JSON by distributing the new STH.
77 void OnJsonParseSuccess(std::string log_id,
Sorin Jianu 2016/04/07 15:49:48 maybe pass be reference to const instead of by val
Eran Messeri 2016/04/07 16:37:59 Done.
78 scoped_ptr<base::Value> parsed_json);
79
80 // STH parsing failed - do nothing.
81 void OnJsonParseError(std::string log_id, const std::string& error);
Sorin Jianu 2016/04/07 15:49:49 same
Eran Messeri 2016/04/07 16:37:59 Done.
82
83 scoped_ptr<net::ct::STHObserver> sth_observer_;
84
85 DISALLOW_COPY_AND_ASSIGN(STHSetComponentInstallerTraits);
86 };
87
88 void RegisterSTHSetComponent(ComponentUpdateService* cus,
89 const base::FilePath& user_data_dir);
90
91 } // namespace component_updater
92
93 #endif // CHROME_BROWSER_COMPONENT_UPDATER_STH_SET_COMPONENT_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698