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 CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "chrome/browser/component_updater/default_component_installer.h" | 13 #include "chrome/browser/component_updater/default_component_installer.h" |
14 | 14 |
15 namespace test { | 15 namespace test { |
16 class ScopedCLDDynamicDataHarness; | 16 class ScopedCLDDynamicDataHarness; |
17 } // namespace test | 17 } // namespace test |
18 | 18 |
19 namespace component_updater { | 19 namespace component_updater { |
20 | 20 |
21 class ComponentUpdateService; | 21 class ComponentUpdateService; |
22 | 22 |
23 // Visible for testing. No need to instantiate this class directly. | 23 // Visible for testing. No need to instantiate this class directly. |
24 class CldComponentInstallerTraits : public ComponentInstallerTraits { | 24 class CldComponentInstallerTraits : public ComponentInstallerTraits { |
25 public: | 25 public: |
26 CldComponentInstallerTraits(); | 26 CldComponentInstallerTraits(const base::FilePath& base_dir, |
27 const base::FilePath& data_filename); | |
27 virtual ~CldComponentInstallerTraits() {} | 28 virtual ~CldComponentInstallerTraits() {} |
28 | 29 |
29 private: | 30 private: |
30 friend class CldComponentInstallerTest; // For access within SetUp() | 31 friend class CldComponentInstallerTest; // For access within SetUp() |
31 friend class test::ScopedCLDDynamicDataHarness; // For browser tests only | 32 friend class test::ScopedCLDDynamicDataHarness; // For browser tests only |
32 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady); | 33 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, ComponentReady); |
33 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory); | 34 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetBaseDirectory); |
34 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash); | 35 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetHash); |
35 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath); | 36 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetInstalledPath); |
36 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName); | 37 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, GetName); |
37 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall); | 38 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, OnCustomInstall); |
38 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile); | 39 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, SetLatestCldDataFile); |
39 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation); | 40 FRIEND_TEST_ALL_PREFIXES(CldComponentInstallerTest, VerifyInstallation); |
40 | 41 |
41 // The following methods override ComponentInstallerTraits. | 42 // The following methods override ComponentInstallerTraits. |
42 virtual bool CanAutoUpdate() const OVERRIDE; | 43 virtual bool CanAutoUpdate() const OVERRIDE; |
43 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, | 44 virtual bool OnCustomInstall(const base::DictionaryValue& manifest, |
44 const base::FilePath& install_dir) OVERRIDE; | 45 const base::FilePath& install_dir) OVERRIDE; |
45 virtual bool VerifyInstallation( | 46 virtual bool VerifyInstallation( |
46 const base::FilePath& install_dir) const OVERRIDE; | 47 const base::FilePath& install_dir) const OVERRIDE; |
47 virtual void ComponentReady( | 48 virtual void ComponentReady( |
48 const base::Version& version, | 49 const base::Version& version, |
49 const base::FilePath& path, | 50 const base::FilePath& path, |
50 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; | 51 scoped_ptr<base::DictionaryValue> manifest) OVERRIDE; |
51 virtual base::FilePath GetBaseDirectory() const OVERRIDE; | 52 virtual base::FilePath GetBaseDirectory() const OVERRIDE; |
52 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; | 53 virtual void GetHash(std::vector<uint8>* hash) const OVERRIDE; |
53 virtual std::string GetName() const OVERRIDE; | 54 virtual std::string GetName() const OVERRIDE; |
54 | 55 |
55 static base::FilePath GetInstalledPath(const base::FilePath& base); | 56 base::FilePath GetInstalledPath(const base::FilePath& base) const; |
Sorin Jianu
2014/06/19 00:48:22
It would be nice to not have to touch the definiti
tommycli
2014/06/23 21:55:28
Done.
| |
56 static void SetLatestCldDataFile(const base::FilePath& path); | 57 static void SetLatestCldDataFile(const base::FilePath& path); |
58 | |
59 base::FilePath base_dir_; | |
60 base::FilePath data_filename_; | |
61 | |
57 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits); | 62 DISALLOW_COPY_AND_ASSIGN(CldComponentInstallerTraits); |
58 }; | 63 }; |
59 | 64 |
60 // Call once during startup to make the component update service aware of | 65 // Call once during startup to make the component update service aware of |
61 // the CLD component. | 66 // the CLD component. |
62 void RegisterCldComponent(ComponentUpdateService* cus); | 67 void RegisterCldComponent(ComponentUpdateService* cus, |
68 const base::FilePath& base_dir, | |
69 const base::FilePath& data_filename); | |
63 | 70 |
64 // Returns the path to the latest CLD data file into the specified path object, | 71 // Returns the path to the latest CLD data file into the specified path object, |
65 // or an empty path if the CLD data file has not been observed yet. | 72 // or an empty path if the CLD data file has not been observed yet. |
66 // This function is threadsafe. | 73 // This function is threadsafe. |
67 base::FilePath GetLatestCldDataFile(); | 74 base::FilePath GetLatestCldDataFile(); |
68 | 75 |
69 } // namespace component_updater | 76 } // namespace component_updater |
70 | 77 |
71 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ | 78 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CLD_COMPONENT_INSTALLER_H_ |
OLD | NEW |