| OLD | NEW |
| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 known_timezone = &timezone; | 386 known_timezone = &timezone; |
| 387 | 387 |
| 388 timezone_.reset(known_timezone->clone()); | 388 timezone_.reset(known_timezone->clone()); |
| 389 std::string id = base::UTF16ToUTF8(GetTimezoneID(*known_timezone)); | 389 std::string id = base::UTF16ToUTF8(GetTimezoneID(*known_timezone)); |
| 390 VLOG(1) << "Setting timezone to " << id; | 390 VLOG(1) << "Setting timezone to " << id; |
| 391 // It's safe to change the timezone config files in the background as the | 391 // It's safe to change the timezone config files in the background as the |
| 392 // following operations don't depend on the completion of the config change. | 392 // following operations don't depend on the completion of the config change. |
| 393 base::WorkerPool::GetTaskRunner(true /* task is slow */)-> | 393 base::WorkerPool::GetTaskRunner(true /* task is slow */)-> |
| 394 PostTask(FROM_HERE, base::Bind(&SetTimezoneIDFromString, id)); | 394 PostTask(FROM_HERE, base::Bind(&SetTimezoneIDFromString, id)); |
| 395 icu::TimeZone::setDefault(*known_timezone); | 395 icu::TimeZone::setDefault(*known_timezone); |
| 396 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(*known_timezone)); | 396 for (auto& observer : observers_) |
| 397 observer.TimezoneChanged(*known_timezone); |
| 397 } | 398 } |
| 398 | 399 |
| 399 // static | 400 // static |
| 400 TimezoneSettingsImpl* TimezoneSettingsImpl::GetInstance() { | 401 TimezoneSettingsImpl* TimezoneSettingsImpl::GetInstance() { |
| 401 return base::Singleton< | 402 return base::Singleton< |
| 402 TimezoneSettingsImpl, | 403 TimezoneSettingsImpl, |
| 403 base::DefaultSingletonTraits<TimezoneSettingsImpl>>::get(); | 404 base::DefaultSingletonTraits<TimezoneSettingsImpl>>::get(); |
| 404 } | 405 } |
| 405 | 406 |
| 406 TimezoneSettingsImpl::TimezoneSettingsImpl() { | 407 TimezoneSettingsImpl::TimezoneSettingsImpl() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 433 // Replace |timezone| by a known timezone with the same rules. If none exists | 434 // Replace |timezone| by a known timezone with the same rules. If none exists |
| 434 // go on with |timezone|. | 435 // go on with |timezone|. |
| 435 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone); | 436 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone); |
| 436 if (!known_timezone) | 437 if (!known_timezone) |
| 437 known_timezone = &timezone; | 438 known_timezone = &timezone; |
| 438 | 439 |
| 439 std::string id = base::UTF16ToUTF8(GetTimezoneID(*known_timezone)); | 440 std::string id = base::UTF16ToUTF8(GetTimezoneID(*known_timezone)); |
| 440 VLOG(1) << "Setting timezone to " << id; | 441 VLOG(1) << "Setting timezone to " << id; |
| 441 timezone_.reset(known_timezone->clone()); | 442 timezone_.reset(known_timezone->clone()); |
| 442 icu::TimeZone::setDefault(*known_timezone); | 443 icu::TimeZone::setDefault(*known_timezone); |
| 443 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(*known_timezone)); | 444 for (auto& observer : observers_) |
| 445 observer.TimezoneChanged(*known_timezone); |
| 444 } | 446 } |
| 445 | 447 |
| 446 // static | 448 // static |
| 447 TimezoneSettingsStubImpl* TimezoneSettingsStubImpl::GetInstance() { | 449 TimezoneSettingsStubImpl* TimezoneSettingsStubImpl::GetInstance() { |
| 448 return base::Singleton< | 450 return base::Singleton< |
| 449 TimezoneSettingsStubImpl, | 451 TimezoneSettingsStubImpl, |
| 450 base::DefaultSingletonTraits<TimezoneSettingsStubImpl>>::get(); | 452 base::DefaultSingletonTraits<TimezoneSettingsStubImpl>>::get(); |
| 451 } | 453 } |
| 452 | 454 |
| 453 TimezoneSettingsStubImpl::TimezoneSettingsStubImpl() { | 455 TimezoneSettingsStubImpl::TimezoneSettingsStubImpl() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 475 | 477 |
| 476 // static | 478 // static |
| 477 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { | 479 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { |
| 478 icu::UnicodeString id; | 480 icu::UnicodeString id; |
| 479 timezone.getID(id); | 481 timezone.getID(id); |
| 480 return base::string16(id.getBuffer(), id.length()); | 482 return base::string16(id.getBuffer(), id.length()); |
| 481 } | 483 } |
| 482 | 484 |
| 483 } // namespace system | 485 } // namespace system |
| 484 } // namespace chromeos | 486 } // namespace chromeos |
| OLD | NEW |