| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file defines helper methods used to schedule files for deletion | 5 // This file defines helper methods used to schedule files for deletion |
| 6 // on next reboot. The code here is heavily borrowed and simplified from | 6 // on next reboot. The code here is heavily borrowed and simplified from |
| 7 // http://code.google.com/p/omaha/source/browse/trunk/common/file.cc and | 7 // http://code.google.com/p/omaha/source/browse/trunk/common/file.cc and |
| 8 // http://code.google.com/p/omaha/source/browse/trunk/common/utils.cc | 8 // http://code.google.com/p/omaha/source/browse/trunk/common/utils.cc |
| 9 // | 9 // |
| 10 // This implementation really is not fast, so do not use it where that will | 10 // This implementation really is not fast, so do not use it where that will |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 return S_OK; | 190 return S_OK; |
| 191 } | 191 } |
| 192 | 192 |
| 193 void StringArrayToMultiSZBytes(const std::vector<PendingMove>& strings, | 193 void StringArrayToMultiSZBytes(const std::vector<PendingMove>& strings, |
| 194 std::vector<char>* buffer) { | 194 std::vector<char>* buffer) { |
| 195 DCHECK(buffer); | 195 DCHECK(buffer); |
| 196 buffer->clear(); | 196 buffer->clear(); |
| 197 | 197 |
| 198 if (strings.size() == 0) { | 198 if (strings.empty()) { |
| 199 // Leave buffer empty if we have no strings. | 199 // Leave buffer empty if we have no strings. |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 size_t total_wchars = 0; | 203 size_t total_wchars = 0; |
| 204 { | 204 { |
| 205 std::vector<PendingMove>::const_iterator iter(strings.begin()); | 205 std::vector<PendingMove>::const_iterator iter(strings.begin()); |
| 206 for (; iter != strings.end(); ++iter) { | 206 for (; iter != strings.end(); ++iter) { |
| 207 total_wchars += iter->first.length(); | 207 total_wchars += iter->first.length(); |
| 208 total_wchars++; // Space for the null char. | 208 total_wchars++; // Space for the null char. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 ERROR_SUCCESS); | 383 ERROR_SUCCESS); |
| 384 } | 384 } |
| 385 std::vector<char> buffer; | 385 std::vector<char> buffer; |
| 386 StringArrayToMultiSZBytes(strings_to_keep, &buffer); | 386 StringArrayToMultiSZBytes(strings_to_keep, &buffer); |
| 387 DCHECK_GT(buffer.size(), 0U); | 387 DCHECK_GT(buffer.size(), 0U); |
| 388 if (buffer.empty()) | 388 if (buffer.empty()) |
| 389 return false; | 389 return false; |
| 390 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], | 390 return (session_manager_key.WriteValue(kPendingFileRenameOps, &buffer[0], |
| 391 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); | 391 buffer.size(), REG_MULTI_SZ) == ERROR_SUCCESS); |
| 392 } | 392 } |
| OLD | NEW |