OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 PLOG(ERROR) << "ftruncate settings file"; | 209 PLOG(ERROR) << "ftruncate settings file"; |
210 return false; | 210 return false; |
211 } | 211 } |
212 | 212 |
213 return LoggingWriteFile(handle, &data, sizeof(Data)); | 213 return LoggingWriteFile(handle, &data, sizeof(Data)); |
214 } | 214 } |
215 | 215 |
216 bool Settings::RecoverSettings(FileHandle handle, Data* out_data) { | 216 bool Settings::RecoverSettings(FileHandle handle, Data* out_data) { |
217 ScopedFileHandle scoped_handle; | 217 ScopedFileHandle scoped_handle; |
218 if (handle == kInvalidFileHandle) { | 218 if (handle == kInvalidFileHandle) { |
219 scoped_handle.reset(OpenForReadingAndWriting().release()); | 219 scoped_handle = OpenForReadingAndWriting(); |
220 handle = scoped_handle.get(); | 220 handle = scoped_handle.get(); |
221 | 221 |
222 // Test if the file has already been recovered now that the exclusive lock | 222 // Test if the file has already been recovered now that the exclusive lock |
223 // is held. | 223 // is held. |
224 if (ReadSettings(handle, out_data)) | 224 if (ReadSettings(handle, out_data)) |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 LOG(INFO) << "Recovering settings file " << file_path().value(); | 228 LOG(INFO) << "Recovering settings file " << file_path().value(); |
229 | 229 |
(...skipping 12 matching lines...) Expand all Loading... |
242 uuid_t uuid; | 242 uuid_t uuid; |
243 uuid_generate(uuid); | 243 uuid_generate(uuid); |
244 | 244 |
245 Data settings; | 245 Data settings; |
246 settings.client_id.InitializeFromBytes(uuid); | 246 settings.client_id.InitializeFromBytes(uuid); |
247 | 247 |
248 return WriteSettings(handle, settings); | 248 return WriteSettings(handle, settings); |
249 } | 249 } |
250 | 250 |
251 } // namespace crashpad | 251 } // namespace crashpad |
OLD | NEW |