OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chromecast/crash/linux/crash_testing_utils.h" | 5 #include "chromecast/crash/linux/crash_testing_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (!(contents = ParseLockFile(lockfile_path))) { | 136 if (!(contents = ParseLockFile(lockfile_path))) { |
137 return false; | 137 return false; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 contents->Append(dump.GetAsValue()); | 141 contents->Append(dump.GetAsValue()); |
142 | 142 |
143 return WriteLockFile(lockfile_path, contents.get()) == 0; | 143 return WriteLockFile(lockfile_path, contents.get()) == 0; |
144 } | 144 } |
145 | 145 |
146 bool SetRatelimitPeriodStart(const std::string& metadata_path, time_t start) { | 146 bool SetRatelimitPeriodStart(const std::string& metadata_path, |
| 147 const base::Time& start) { |
147 std::unique_ptr<base::Value> contents = ParseMetadataFile(metadata_path); | 148 std::unique_ptr<base::Value> contents = ParseMetadataFile(metadata_path); |
148 | 149 |
149 base::DictionaryValue* dict; | 150 base::DictionaryValue* dict; |
150 base::DictionaryValue* ratelimit_params; | 151 base::DictionaryValue* ratelimit_params; |
151 if (!contents || !contents->GetAsDictionary(&dict) || | 152 if (!contents || !contents->GetAsDictionary(&dict) || |
152 !dict->GetDictionary(kRatelimitKey, &ratelimit_params)) { | 153 !dict->GetDictionary(kRatelimitKey, &ratelimit_params)) { |
153 return false; | 154 return false; |
154 } | 155 } |
155 | 156 |
156 std::string period_start_str = | 157 ratelimit_params->SetDouble(kRatelimitPeriodStartKey, start.ToDoubleT()); |
157 base::StringPrintf("%lld", static_cast<long long>(start)); | |
158 ratelimit_params->SetString(kRatelimitPeriodStartKey, period_start_str); | |
159 | |
160 return WriteMetadataFile(metadata_path, contents.get()) == 0; | 158 return WriteMetadataFile(metadata_path, contents.get()) == 0; |
161 } | 159 } |
162 | 160 |
163 } // namespace chromecast | 161 } // namespace chromecast |
OLD | NEW |