| Index: content/browser/time_zone_monitor.cc
|
| diff --git a/content/browser/time_zone_monitor.cc b/content/browser/time_zone_monitor.cc
|
| index a9a5a9b6c53689695468bb91294d934281e89c67..c2f1b81d1a04de82537998dbbc58d130285a4400 100644
|
| --- a/content/browser/time_zone_monitor.cc
|
| +++ b/content/browser/time_zone_monitor.cc
|
| @@ -7,7 +7,6 @@
|
| #include "base/logging.h"
|
| #include "build/build_config.h"
|
| #include "content/public/browser/browser_thread.h"
|
| -#include "content/public/browser/render_process_host.h"
|
| #include "third_party/icu/source/common/unicode/unistr.h"
|
| #include "third_party/icu/source/i18n/unicode/timezone.h"
|
|
|
| @@ -19,9 +18,19 @@ TimeZoneMonitor::TimeZoneMonitor() {
|
|
|
| TimeZoneMonitor::~TimeZoneMonitor() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + // Explicitly tear down the connections so that the callbacks in
|
| + // |on_time_zone_change_tasks_| can safely be destroyed (otherwise they
|
| + // can DCHECK due to being destroyed unfilled while their connection is
|
| + // still active).
|
| + bindings_.CloseAllBindings();
|
| +}
|
| +
|
| +void TimeZoneMonitor::Bind(device::mojom::TimeZoneMonitorRequest request) {
|
| + bindings_.AddBinding(this, std::move(request));
|
| }
|
|
|
| -void TimeZoneMonitor::NotifyRenderers() {
|
| +void TimeZoneMonitor::NotifyClients() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| #if defined(OS_CHROMEOS)
|
| // On CrOS, ICU's default tz is already set to a new zone. No
|
| @@ -45,12 +54,18 @@ void TimeZoneMonitor::NotifyRenderers() {
|
| std::string zone_id_str;
|
| new_zone->getID(zone_id).toUTF8String(zone_id_str);
|
| VLOG(1) << "timezone reset to " << zone_id_str;
|
| - for (RenderProcessHost::iterator iterator =
|
| - RenderProcessHost::AllHostsIterator();
|
| - !iterator.IsAtEnd();
|
| - iterator.Advance()) {
|
| - iterator.GetCurrentValue()->NotifyTimezoneChange(zone_id_str);
|
| - }
|
| +
|
| + std::vector<device::mojom::TimeZoneMonitor::QueryNextTimeZoneChangeCallback>
|
| + tasks;
|
| + on_time_zone_change_tasks_.swap(tasks);
|
| + for (auto& task : tasks)
|
| + task.Run(zone_id_str);
|
| +}
|
| +
|
| +void TimeZoneMonitor::QueryNextTimeZoneChange(
|
| + const device::mojom::TimeZoneMonitor::QueryNextTimeZoneChangeCallback&
|
| + callback) {
|
| + on_time_zone_change_tasks_.push_back(callback);
|
| }
|
|
|
| } // namespace content
|
|
|