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

Side by Side Diff: chrome/browser/chromeos/system/timezone_settings.cc

Issue 7904012: Make file IO occur on the right thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 9 years, 3 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 | Annotate | Revision Log
« 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 (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/browser/chromeos/system/timezone_settings.h" 5 #include "chrome/browser/chromeos/system/timezone_settings.h"
6 6
7 #include "base/bind.h"
7 #include "base/file_path.h" 8 #include "base/file_path.h"
8 #include "base/file_util.h" 9 #include "base/file_util.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/observer_list.h" 11 #include "base/observer_list.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "content/browser/browser_thread.h"
15 17
16 namespace chromeos { 18 namespace chromeos {
17 namespace system { 19 namespace system {
18 20
19 namespace { 21 namespace {
20 22
21 // The filepath to the timezone file that symlinks to the actual timezone file. 23 // The filepath to the timezone file that symlinks to the actual timezone file.
22 const char kTimezoneSymlink[] = "/var/lib/timezone/localtime"; 24 const char kTimezoneSymlink[] = "/var/lib/timezone/localtime";
23 const char kTimezoneSymlink2[] = "/var/lib/timezone/localtime2"; 25 const char kTimezoneSymlink2[] = "/var/lib/timezone/localtime2";
24 26
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return *timezone_.get(); 115 return *timezone_.get();
114 } 116 }
115 117
116 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) { 118 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) {
117 timezone_.reset(timezone.clone()); 119 timezone_.reset(timezone.clone());
118 icu::UnicodeString unicode; 120 icu::UnicodeString unicode;
119 timezone.getID(unicode); 121 timezone.getID(unicode);
120 std::string id; 122 std::string id;
121 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &id); 123 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &id);
122 VLOG(1) << "Setting timezone to " << id; 124 VLOG(1) << "Setting timezone to " << id;
123 SetTimezoneIDFromString(id); 125 // Change the timezone config files on the FILE thread. It's safe to do this
126 // in the background as the following operations don't depend on the
127 // completion of the config change.
128 BrowserThread::PostTask(BrowserThread::FILE,
129 FROM_HERE,
130 base::Bind(&SetTimezoneIDFromString, id));
124 icu::TimeZone::setDefault(timezone); 131 icu::TimeZone::setDefault(timezone);
125 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(timezone)); 132 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(timezone));
126 } 133 }
127 134
128 void TimezoneSettingsImpl::AddObserver(Observer* observer) { 135 void TimezoneSettingsImpl::AddObserver(Observer* observer) {
129 observers_.AddObserver(observer); 136 observers_.AddObserver(observer);
130 } 137 }
131 138
132 void TimezoneSettingsImpl::RemoveObserver(Observer* observer) { 139 void TimezoneSettingsImpl::RemoveObserver(Observer* observer) {
133 observers_.RemoveObserver(observer); 140 observers_.RemoveObserver(observer);
(...skipping 21 matching lines...) Expand all
155 TimezoneSettings* TimezoneSettings::GetInstance() { 162 TimezoneSettings* TimezoneSettings::GetInstance() {
156 return TimezoneSettingsImpl::GetInstance(); 163 return TimezoneSettingsImpl::GetInstance();
157 } 164 }
158 165
159 } // namespace system 166 } // namespace system
160 } // namespace chromeos 167 } // namespace chromeos
161 168
162 // Allows InvokeLater without adding refcounting. TimezoneSettingsImpl is a 169 // Allows InvokeLater without adding refcounting. TimezoneSettingsImpl is a
163 // Singleton and won't be deleted until it's last InvokeLater is run. 170 // Singleton and won't be deleted until it's last InvokeLater is run.
164 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::TimezoneSettingsImpl); 171 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::TimezoneSettingsImpl);
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