OLD | NEW |
---|---|
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/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "content/browser/browser_thread.h" | |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 namespace system { | 18 namespace system { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // The filepath to the timezone file that symlinks to the actual timezone file. | 22 // The filepath to the timezone file that symlinks to the actual timezone file. |
22 const char kTimezoneSymlink[] = "/var/lib/timezone/localtime"; | 23 const char kTimezoneSymlink[] = "/var/lib/timezone/localtime"; |
23 const char kTimezoneSymlink2[] = "/var/lib/timezone/localtime2"; | 24 const char kTimezoneSymlink2[] = "/var/lib/timezone/localtime2"; |
24 | 25 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 return *timezone_.get(); | 114 return *timezone_.get(); |
114 } | 115 } |
115 | 116 |
116 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) { | 117 void TimezoneSettingsImpl::SetTimezone(const icu::TimeZone& timezone) { |
117 timezone_.reset(timezone.clone()); | 118 timezone_.reset(timezone.clone()); |
118 icu::UnicodeString unicode; | 119 icu::UnicodeString unicode; |
119 timezone.getID(unicode); | 120 timezone.getID(unicode); |
120 std::string id; | 121 std::string id; |
121 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &id); | 122 UTF16ToUTF8(unicode.getBuffer(), unicode.length(), &id); |
122 VLOG(1) << "Setting timezone to " << id; | 123 VLOG(1) << "Setting timezone to " << id; |
123 SetTimezoneIDFromString(id); | 124 BrowserThread::PostTask(BrowserThread::FILE, |
satorux1
2011/09/19 16:49:03
I think it's safe to do SetTimezoneIDFromString()
pastarmovj
2011/09/20 12:04:12
Done.
| |
125 FROM_HERE, | |
126 NewRunnableFunction(&SetTimezoneIDFromString, id)); | |
satorux1
2011/09/19 16:49:03
Can you use base::Bind() instead? NewRunnableFunct
pastarmovj
2011/09/20 12:04:12
Done.
| |
124 icu::TimeZone::setDefault(timezone); | 127 icu::TimeZone::setDefault(timezone); |
125 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(timezone)); | 128 FOR_EACH_OBSERVER(Observer, observers_, TimezoneChanged(timezone)); |
126 } | 129 } |
127 | 130 |
128 void TimezoneSettingsImpl::AddObserver(Observer* observer) { | 131 void TimezoneSettingsImpl::AddObserver(Observer* observer) { |
129 observers_.AddObserver(observer); | 132 observers_.AddObserver(observer); |
130 } | 133 } |
131 | 134 |
132 void TimezoneSettingsImpl::RemoveObserver(Observer* observer) { | 135 void TimezoneSettingsImpl::RemoveObserver(Observer* observer) { |
133 observers_.RemoveObserver(observer); | 136 observers_.RemoveObserver(observer); |
(...skipping 21 matching lines...) Expand all Loading... | |
155 TimezoneSettings* TimezoneSettings::GetInstance() { | 158 TimezoneSettings* TimezoneSettings::GetInstance() { |
156 return TimezoneSettingsImpl::GetInstance(); | 159 return TimezoneSettingsImpl::GetInstance(); |
157 } | 160 } |
158 | 161 |
159 } // namespace system | 162 } // namespace system |
160 } // namespace chromeos | 163 } // namespace chromeos |
161 | 164 |
162 // Allows InvokeLater without adding refcounting. TimezoneSettingsImpl is a | 165 // Allows InvokeLater without adding refcounting. TimezoneSettingsImpl is a |
163 // Singleton and won't be deleted until it's last InvokeLater is run. | 166 // Singleton and won't be deleted until it's last InvokeLater is run. |
164 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::TimezoneSettingsImpl); | 167 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::TimezoneSettingsImpl); |
OLD | NEW |