| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/time_zone_monitor/TimeZoneMonitorClient.h" | 5 #include "modules/time_zone_monitor/TimeZoneMonitorClient.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "bindings/core/v8/V8PerIsolateData.h" | 8 #include "bindings/core/v8/V8PerIsolateData.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/ExecutionContextTask.h" | 10 #include "core/dom/ExecutionContextTask.h" |
| 11 #include "core/workers/WorkerBackingThread.h" | 11 #include "core/workers/WorkerBackingThread.h" |
| 12 #include "core/workers/WorkerThread.h" | 12 #include "core/workers/WorkerThread.h" |
| 13 #include "platform/ServiceConnector.h" | 13 #include "public/platform/InterfaceProvider.h" |
| 14 #include "public/platform/Platform.h" | 14 #include "public/platform/Platform.h" |
| 15 #include "services/device/public/interfaces/constants.mojom-blink.h" | |
| 16 #include "third_party/icu/source/i18n/unicode/timezone.h" | 15 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 17 #include <v8.h> | 16 #include <v8.h> |
| 18 | 17 |
| 19 namespace blink { | 18 namespace blink { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 // Notify V8 that the date/time configuration of the system might have changed. | 22 // Notify V8 that the date/time configuration of the system might have changed. |
| 24 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) { | 23 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) { |
| 25 DCHECK(isolate); | 24 DCHECK(isolate); |
| 26 v8::Date::DateTimeConfigurationChangeNotification(isolate); | 25 v8::Date::DateTimeConfigurationChangeNotification(isolate); |
| 27 } | 26 } |
| 28 | 27 |
| 29 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) { | 28 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) { |
| 30 NotifyTimezoneChangeToV8(toIsolate(context)); | 29 NotifyTimezoneChangeToV8(toIsolate(context)); |
| 31 } | 30 } |
| 32 | 31 |
| 33 } // namespace | 32 } // namespace |
| 34 | 33 |
| 35 // static | 34 // static |
| 36 void TimeZoneMonitorClient::Init() { | 35 void TimeZoneMonitorClient::Init() { |
| 37 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ()); | 36 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ()); |
| 38 | 37 |
| 39 device::mojom::blink::TimeZoneMonitorPtr monitor; | 38 device::mojom::blink::TimeZoneMonitorPtr monitor; |
| 40 ServiceConnector::instance().connectToInterface( | 39 Platform::current()->interfaceProvider()->getInterface( |
| 41 device::mojom::blink::kServiceName, mojo::GetProxy(&monitor)); | 40 mojo::GetProxy(&monitor)); |
| 42 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind()); | 41 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind()); |
| 43 } | 42 } |
| 44 | 43 |
| 45 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { | 44 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { |
| 46 DCHECK(isMainThread()); | 45 DCHECK(isMainThread()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} | 48 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} |
| 50 | 49 |
| 51 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) { | 50 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 // among multiple WorkerThreads. | 67 // among multiple WorkerThreads. |
| 69 if (posted.contains(&thread->workerBackingThread())) | 68 if (posted.contains(&thread->workerBackingThread())) |
| 70 continue; | 69 continue; |
| 71 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask( | 70 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask( |
| 72 &NotifyTimezoneChangeOnWorkerThread)); | 71 &NotifyTimezoneChangeOnWorkerThread)); |
| 73 posted.add(&thread->workerBackingThread()); | 72 posted.add(&thread->workerBackingThread()); |
| 74 } | 73 } |
| 75 } | 74 } |
| 76 | 75 |
| 77 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |