Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/installer/util/delete_tree_work_item.cc

Issue 821673004: replace COMPILE_ASSERT with static_assert in chrome/installer/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/installer/util/delete_tree_work_item.h" 5 #include "chrome/installer/util/delete_tree_work_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Casts a value of an unsigned type to a signed type of the same size provided 15 // Casts a value of an unsigned type to a signed type of the same size provided
16 // that there is no overflow. 16 // that there is no overflow.
17 template<typename L, typename R> 17 template<typename L, typename R>
18 bool SafeCast(L left, R* right) { 18 bool SafeCast(L left, R* right) {
19 DCHECK(right); 19 DCHECK(right);
20 COMPILE_ASSERT(sizeof(left) == sizeof(right), 20 static_assert(sizeof(left) == sizeof(right),
21 must_add_support_for_crazy_data_types); 21 "must add support for crazy data types");
22 if (left > static_cast<L>(std::numeric_limits<R>::max())) 22 if (left > static_cast<L>(std::numeric_limits<R>::max()))
23 return false; 23 return false;
24 *right = static_cast<L>(left); 24 *right = static_cast<L>(left);
25 return true; 25 return true;
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 DeleteTreeWorkItem::DeleteTreeWorkItem( 30 DeleteTreeWorkItem::DeleteTreeWorkItem(
31 const base::FilePath& root_path, 31 const base::FilePath& root_path,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 backup_dir.path().Append(key_file.BaseName()); 155 backup_dir.path().Append(key_file.BaseName());
156 if (base::PathExists(backup_file) && 156 if (base::PathExists(backup_file) &&
157 !base::Move(backup_file, key_file)) { 157 !base::Move(backup_file, key_file)) {
158 // This could happen if we could not delete the key file to begin with. 158 // This could happen if we could not delete the key file to begin with.
159 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " 159 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: "
160 << backup_file.value() << " to " << key_file.value(); 160 << backup_file.value() << " to " << key_file.value();
161 } 161 }
162 } 162 }
163 } 163 }
164 } 164 }
OLDNEW
« no previous file with comments | « chrome/installer/util/channel_info.cc ('k') | chrome/installer/util/google_update_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698