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

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

Issue 2611433002: Use TaskScheduler instead of WorkerPool in timezone_settings.cc. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/memory/singleton.h" 19 #include "base/memory/singleton.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/sys_info.h" 23 #include "base/sys_info.h"
24 #include "base/task_runner.h" 24 #include "base/task_runner.h"
25 #include "base/threading/worker_pool.h" 25 #include "base/task_scheduler/post_task.h"
26 #include "chromeos/settings/timezone_settings_helper.h" 26 #include "chromeos/settings/timezone_settings_helper.h"
27 27
28 namespace chromeos { 28 namespace chromeos {
29 namespace system { 29 namespace system {
30 const char kUTCTimezoneName[] = "Etc/GMT"; 30 const char kUTCTimezoneName[] = "Etc/GMT";
31 } 31 }
32 } 32 }
33 33
34 namespace { 34 namespace {
35 35
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // go on with |timezone|. 383 // go on with |timezone|.
384 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone); 384 const icu::TimeZone* known_timezone = GetKnownTimezoneOrNull(timezone);
385 if (!known_timezone) 385 if (!known_timezone)
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::PostTaskWithTraits(
394 PostTask(FROM_HERE, base::Bind(&SetTimezoneIDFromString, id)); 394 FROM_HERE, base::TaskTraits()
395 .WithShutdownBehavior(
396 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
397 .WithPriority(base::TaskPriority::BACKGROUND)
398 .MayBlock(),
399 base::Bind(&SetTimezoneIDFromString, id));
395 icu::TimeZone::setDefault(*known_timezone); 400 icu::TimeZone::setDefault(*known_timezone);
396 for (auto& observer : observers_) 401 for (auto& observer : observers_)
397 observer.TimezoneChanged(*known_timezone); 402 observer.TimezoneChanged(*known_timezone);
398 } 403 }
399 404
400 // static 405 // static
401 TimezoneSettingsImpl* TimezoneSettingsImpl::GetInstance() { 406 TimezoneSettingsImpl* TimezoneSettingsImpl::GetInstance() {
402 return base::Singleton< 407 return base::Singleton<
403 TimezoneSettingsImpl, 408 TimezoneSettingsImpl,
404 base::DefaultSingletonTraits<TimezoneSettingsImpl>>::get(); 409 base::DefaultSingletonTraits<TimezoneSettingsImpl>>::get();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 482
478 // static 483 // static
479 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) { 484 base::string16 TimezoneSettings::GetTimezoneID(const icu::TimeZone& timezone) {
480 icu::UnicodeString id; 485 icu::UnicodeString id;
481 timezone.getID(id); 486 timezone.getID(id);
482 return base::string16(id.getBuffer(), id.length()); 487 return base::string16(id.getBuffer(), id.length());
483 } 488 }
484 489
485 } // namespace system 490 } // namespace system
486 } // namespace chromeos 491 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698