OLD | NEW |
---|---|
1 | 1 |
2 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include "components/update_client/updater_state.h" | 6 #include "components/update_client/updater_state.h" |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 | 14 |
15 namespace update_client { | 15 namespace update_client { |
16 | 16 |
17 const char UpdaterState::kDomainJoined[] = "domainjoined"; | 17 const char UpdaterState::kIsEnterpriseUser[] = "domainjoined"; |
Roger Tawa OOO till Jul 10th
2016/12/16 21:00:53
I changed the name of the constant but not the val
Georges Khalil
2017/02/09 14:59:57
I think you are right, that it is persisted. But I
| |
18 | 18 |
19 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} | 19 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} |
20 | 20 |
21 UpdaterState::~UpdaterState() {} | 21 UpdaterState::~UpdaterState() {} |
22 | 22 |
23 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( | 23 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( |
24 bool is_machine) { | 24 bool is_machine) { |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 UpdaterState updater_state(is_machine); | 26 UpdaterState updater_state(is_machine); |
27 updater_state.ReadState(); | 27 updater_state.ReadState(); |
28 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); | 28 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); |
29 #else | 29 #else |
30 return nullptr; | 30 return nullptr; |
31 #endif // OS_WIN | 31 #endif // OS_WIN |
32 } | 32 } |
33 | 33 |
34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
35 void UpdaterState::ReadState() { | 35 void UpdaterState::ReadState() { |
36 is_joined_to_domain_ = IsJoinedToDomain(); | 36 is_enterprise_user_ = IsEnterpriseUser(); |
37 | 37 |
38 #if defined(GOOGLE_CHROME_BUILD) | 38 #if defined(GOOGLE_CHROME_BUILD) |
39 updater_name_ = GetUpdaterName(); | 39 updater_name_ = GetUpdaterName(); |
40 updater_version_ = GetUpdaterVersion(is_machine_); | 40 updater_version_ = GetUpdaterVersion(is_machine_); |
41 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); | 41 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); |
42 last_checked_ = GetUpdaterLastChecked(is_machine_); | 42 last_checked_ = GetUpdaterLastChecked(is_machine_); |
43 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); | 43 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); |
44 update_policy_ = GetUpdatePolicy(); | 44 update_policy_ = GetUpdatePolicy(); |
45 #endif // GOOGLE_CHROME_BUILD | 45 #endif // GOOGLE_CHROME_BUILD |
46 } | 46 } |
47 #endif // OS_WIN | 47 #endif // OS_WIN |
48 | 48 |
49 UpdaterState::Attributes UpdaterState::BuildAttributes() const { | 49 UpdaterState::Attributes UpdaterState::BuildAttributes() const { |
50 Attributes attributes; | 50 Attributes attributes; |
51 | 51 |
52 attributes[kDomainJoined] = is_joined_to_domain_ ? "1" : "0"; | 52 attributes[kIsEnterpriseUser] = is_enterprise_user_ ? "1" : "0"; |
53 | 53 |
54 attributes["name"] = updater_name_; | 54 attributes["name"] = updater_name_; |
55 | 55 |
56 if (updater_version_.IsValid()) | 56 if (updater_version_.IsValid()) |
57 attributes["version"] = updater_version_.GetString(); | 57 attributes["version"] = updater_version_.GetString(); |
58 | 58 |
59 const base::Time now = base::Time::NowFromSystemTime(); | 59 const base::Time now = base::Time::NowFromSystemTime(); |
60 if (!last_autoupdate_started_.is_null()) | 60 if (!last_autoupdate_started_.is_null()) |
61 attributes["laststarted"] = | 61 attributes["laststarted"] = |
62 NormalizeTimeDelta(now - last_autoupdate_started_); | 62 NormalizeTimeDelta(now - last_autoupdate_started_); |
(...skipping 20 matching lines...) Expand all Loading... | |
83 val = "408"; // 2 weeks in hours. | 83 val = "408"; // 2 weeks in hours. |
84 } else { | 84 } else { |
85 val = "1344"; // 2*28 days in hours. | 85 val = "1344"; // 2*28 days in hours. |
86 } | 86 } |
87 | 87 |
88 DCHECK(!val.empty()); | 88 DCHECK(!val.empty()); |
89 return val; | 89 return val; |
90 } | 90 } |
91 | 91 |
92 } // namespace update_client | 92 } // namespace update_client |
OLD | NEW |