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

Side by Side Diff: chromeos/settings/timezone_settings_helper.cc

Issue 2387783002: Remove stl_util's deletion functions from chromeos/. (Closed)
Patch Set: armansito Created 4 years, 2 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 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 "chromeos/settings/timezone_settings_helper.h" 5 #include "chromeos/settings/timezone_settings_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chromeos/chromeos_export.h" 8 #include "chromeos/chromeos_export.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
11 namespace system { 11 namespace system {
12 12
13 CHROMEOS_EXPORT const icu::TimeZone* GetKnownTimezoneOrNull( 13 CHROMEOS_EXPORT const icu::TimeZone* GetKnownTimezoneOrNull(
14 const icu::TimeZone& timezone, 14 const icu::TimeZone& timezone,
15 const std::vector<icu::TimeZone*>& timezone_list) { 15 const std::vector<std::unique_ptr<icu::TimeZone>>& timezone_list) {
16 const icu::TimeZone* known_timezone = NULL; 16 const icu::TimeZone* known_timezone = nullptr;
17 icu::UnicodeString id, canonical_id; 17 icu::UnicodeString id, canonical_id;
18 timezone.getID(id); 18 timezone.getID(id);
19 UErrorCode status = U_ZERO_ERROR; 19 UErrorCode status = U_ZERO_ERROR;
20 icu::TimeZone::getCanonicalID(id, canonical_id, status); 20 icu::TimeZone::getCanonicalID(id, canonical_id, status);
21 DCHECK(U_SUCCESS(status)); 21 DCHECK(U_SUCCESS(status));
22 for (const auto* entry : timezone_list) { 22 for (const auto& entry : timezone_list) {
23 if (*entry == timezone) 23 if (*entry.get() == timezone)
24 return entry; 24 return entry.get();
25 // Compare the canonical IDs as well. 25 // Compare the canonical IDs as well.
26 // For instance, Asia/Ulan_Bator -> Asia/Ulaanbaatar or 26 // For instance, Asia/Ulan_Bator -> Asia/Ulaanbaatar or
27 // Canada/Pacific -> America/Vancouver 27 // Canada/Pacific -> America/Vancouver
28 icu::UnicodeString entry_id, entry_canonical_id; 28 icu::UnicodeString entry_id, entry_canonical_id;
29 entry->getID(entry_id); 29 entry->getID(entry_id);
30 icu::TimeZone::getCanonicalID(entry_id, entry_canonical_id, status); 30 icu::TimeZone::getCanonicalID(entry_id, entry_canonical_id, status);
31 DCHECK(U_SUCCESS(status)); 31 DCHECK(U_SUCCESS(status));
32 if (entry_canonical_id == canonical_id) 32 if (entry_canonical_id == canonical_id)
33 return entry; 33 return entry.get();
34 // Last resort: If no match is found, the last timezone in the list 34 // Last resort: If no match is found, the last timezone in the list
35 // with matching rules will be returned. 35 // with matching rules will be returned.
36 if (entry->hasSameRules(timezone)) 36 if (entry->hasSameRules(timezone))
37 known_timezone = entry; 37 known_timezone = entry.get();
38 } 38 }
39 39
40 // May return NULL if we did not find a matching timezone in our list. 40 // May return null if we did not find a matching timezone in our list.
41 return known_timezone; 41 return known_timezone;
42 } 42 }
43 43
44 } // namespace system 44 } // namespace system
45 } // namespace chromeos 45 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/settings/timezone_settings_helper.h ('k') | chromeos/settings/timezone_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698