| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
| 6 #define COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <string> |
| 11 |
| 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/time/time.h" |
| 14 #include "base/version.h" |
| 15 |
| 16 namespace update_client { |
| 17 |
| 18 class UpdaterState { |
| 19 public: |
| 20 using Attributes = std::map<std::string, std::string>; |
| 21 |
| 22 static const char kDomainJoined[]; |
| 23 |
| 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. |
| 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. |
| 28 static std::unique_ptr<Attributes> GetState(bool is_machine); |
| 29 |
| 30 ~UpdaterState(); |
| 31 |
| 32 private: |
| 33 FRIEND_TEST_ALL_PREFIXES(UpdaterStateTest, Serialize); |
| 34 |
| 35 explicit UpdaterState(bool is_machine); |
| 36 |
| 37 // This function is best-effort. It updates the class members with |
| 38 // the relevant values that could be retrieved. |
| 39 void ReadState(); |
| 40 |
| 41 // Builds the map of state attributes by serializing this object state. |
| 42 Attributes BuildAttributes() const; |
| 43 |
| 44 static std::string GetUpdaterName(); |
| 45 static base::Version GetUpdaterVersion(bool is_machine); |
| 46 static bool IsAutoupdateCheckEnabled(); |
| 47 static bool IsJoinedToDomain(); |
| 48 static base::Time GetUpdaterLastStartedAU(bool is_machine); |
| 49 static base::Time GetUpdaterLastChecked(bool is_machine); |
| 50 static base::Time GetUpdaterTimeValue(bool is_machine, |
| 51 const wchar_t* value_name); |
| 52 static int GetUpdatePolicy(); |
| 53 |
| 54 static std::string NormalizeTimeDelta(const base::TimeDelta& delta); |
| 55 |
| 56 bool is_machine_ = false; |
| 57 std::string updater_name_; |
| 58 base::Version updater_version_; |
| 59 base::Time last_autoupdate_started_; |
| 60 base::Time last_checked_; |
| 61 bool is_joined_to_domain_ = false; |
| 62 bool is_autoupdate_check_enabled_ = false; |
| 63 int update_policy_ = 0; |
| 64 }; |
| 65 |
| 66 } // namespace update_client |
| 67 |
| 68 #endif // COMPONENTS_UPDATE_CLIENT_UPDATER_STATE_H_ |
| OLD | NEW |