OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
6 #define COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 | 15 |
16 namespace update_client { | 16 namespace update_client { |
17 | 17 |
18 class UpdaterState { | 18 class UpdaterState { |
19 public: | 19 public: |
20 using Attributes = std::map<std::string, std::string>; | 20 using Attributes = std::map<std::string, std::string>; |
21 | 21 |
22 static const char kDomainJoined[]; | 22 static const char kIsEnterpriseManaged[]; |
23 | 23 |
24 // Returns a map of items representing the state of an updater. These items | 24 // Returns a map of items representing the state of an updater. These items |
25 // can be serialized as XML attributes in the request building. | 25 // can be serialized as XML attributes in the request building. |
26 // |is_machine| is true for per-system installs of Chrome. Returns nullptr on | 26 // |is_machine| is true for per-system installs of Chrome. Returns nullptr on |
27 // the platforms and builds where this feature is not supported. | 27 // the platforms and builds where this feature is not supported. |
28 static std::unique_ptr<Attributes> GetState(bool is_machine); | 28 static std::unique_ptr<Attributes> GetState(bool is_machine); |
29 | 29 |
30 ~UpdaterState(); | 30 ~UpdaterState(); |
31 | 31 |
32 private: | 32 private: |
33 FRIEND_TEST_ALL_PREFIXES(UpdaterStateTest, Serialize); | 33 FRIEND_TEST_ALL_PREFIXES(UpdaterStateTest, Serialize); |
34 | 34 |
35 explicit UpdaterState(bool is_machine); | 35 explicit UpdaterState(bool is_machine); |
36 | 36 |
37 // This function is best-effort. It updates the class members with | 37 // This function is best-effort. It updates the class members with |
38 // the relevant values that could be retrieved. | 38 // the relevant values that could be retrieved. |
39 void ReadState(); | 39 void ReadState(); |
40 | 40 |
41 // Builds the map of state attributes by serializing this object state. | 41 // Builds the map of state attributes by serializing this object state. |
42 Attributes BuildAttributes() const; | 42 Attributes BuildAttributes() const; |
43 | 43 |
44 static std::string GetUpdaterName(); | 44 static std::string GetUpdaterName(); |
45 static base::Version GetUpdaterVersion(bool is_machine); | 45 static base::Version GetUpdaterVersion(bool is_machine); |
46 static bool IsAutoupdateCheckEnabled(); | 46 static bool IsAutoupdateCheckEnabled(); |
47 static bool IsJoinedToDomain(); | 47 static bool IsEnterpriseManaged(); |
48 static base::Time GetUpdaterLastStartedAU(bool is_machine); | 48 static base::Time GetUpdaterLastStartedAU(bool is_machine); |
49 static base::Time GetUpdaterLastChecked(bool is_machine); | 49 static base::Time GetUpdaterLastChecked(bool is_machine); |
50 static base::Time GetUpdaterTimeValue(bool is_machine, | 50 static base::Time GetUpdaterTimeValue(bool is_machine, |
51 const wchar_t* value_name); | 51 const wchar_t* value_name); |
52 static int GetUpdatePolicy(); | 52 static int GetUpdatePolicy(); |
53 | 53 |
54 static std::string NormalizeTimeDelta(const base::TimeDelta& delta); | 54 static std::string NormalizeTimeDelta(const base::TimeDelta& delta); |
55 | 55 |
56 bool is_machine_ = false; | 56 bool is_machine_ = false; |
57 std::string updater_name_; | 57 std::string updater_name_; |
58 base::Version updater_version_; | 58 base::Version updater_version_; |
59 base::Time last_autoupdate_started_; | 59 base::Time last_autoupdate_started_; |
60 base::Time last_checked_; | 60 base::Time last_checked_; |
61 bool is_joined_to_domain_ = false; | 61 bool is_enterprise_managed_ = false; |
62 bool is_autoupdate_check_enabled_ = false; | 62 bool is_autoupdate_check_enabled_ = false; |
63 int update_policy_ = 0; | 63 int update_policy_ = 0; |
64 }; | 64 }; |
65 | 65 |
66 } // namespace update_client | 66 } // namespace update_client |
67 | 67 |
68 #endif // COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ | 68 #endif // COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
OLD | NEW |