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

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

Issue 2136453004: Reland of place string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.h" 5 #include "chromeos/settings/timezone_settings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const ssize_t len = readlink(kTimezoneSymlink, buf, 216 const ssize_t len = readlink(kTimezoneSymlink, buf,
217 sizeof(buf)-1); 217 sizeof(buf)-1);
218 if (len == -1) { 218 if (len == -1) {
219 LOG(ERROR) << "GetTimezoneID: Cannot read timezone symlink " 219 LOG(ERROR) << "GetTimezoneID: Cannot read timezone symlink "
220 << kTimezoneSymlink; 220 << kTimezoneSymlink;
221 return std::string(); 221 return std::string();
222 } 222 }
223 223
224 std::string timezone(buf, len); 224 std::string timezone(buf, len);
225 // Remove kTimezoneFilesDir from the beginning. 225 // Remove kTimezoneFilesDir from the beginning.
226 if (timezone.find(kTimezoneFilesDir) != 0) { 226 if (!base::StartsWith(timezone, kTimezoneFilesDir,
227 base::CompareCase::SENSITIVE)) {
227 LOG(ERROR) << "GetTimezoneID: Timezone symlink is wrong " 228 LOG(ERROR) << "GetTimezoneID: Timezone symlink is wrong "
228 << timezone; 229 << timezone;
229 return std::string(); 230 return std::string();
230 } 231 }
231 232
232 return timezone.substr(strlen(kTimezoneFilesDir)); 233 return timezone.substr(strlen(kTimezoneFilesDir));
233 } 234 }
234 235
235 void SetTimezoneIDFromString(const std::string& id) { 236 void SetTimezoneIDFromString(const std::string& id) {
236 // Change the kTimezoneSymlink symlink to the path for this timezone. 237 // Change the kTimezoneSymlink symlink to the path for this timezone.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 475
475 // static 476 // static
476 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { 477 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) {
477 icu::UnicodeString id; 478 icu::UnicodeString id;
478 timezone.getID(id); 479 timezone.getID(id);
479 return base::string16(id.getBuffer(), id.length()); 480 return base::string16(id.getBuffer(), id.length());
480 } 481 }
481 482
482 } // namespace system 483 } // namespace system
483 } // namespace chromeos 484 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/session_commands.cc ('k') | components/devtools_http_handler/devtools_http_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698