OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "modules/time_zone_monitor/TimeZoneMonitorClient.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "core/workers/WorkerBackingThread.h" | |
9 #include "public/platform/InterfaceProvider.h" | |
10 #include "public/platform/Platform.h" | |
11 #include "third_party/icu/source/i18n/unicode/timezone.h" | |
12 #include <v8.h> | |
13 | |
14 namespace { | |
15 | |
16 // Notify V8 that the date/time configuration of the system might have changed. | |
17 void NotifyTimezoneChangeOnThisThread() { | |
18 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
haraken
2016/10/11 11:45:06
v8::Isolate::GetCurrent() is deprecated and should
leonhsl(Using Gerrit)
2016/10/12 03:55:55
Acknowledged and will investigate around how to do
| |
19 if (!isolate) | |
20 return; | |
21 v8::Date::DateTimeConfigurationChangeNotification(isolate); | |
22 } | |
23 | |
24 } // namespace | |
25 | |
26 namespace blink { | |
27 | |
28 // static | |
29 void TimeZoneMonitorClient::Init() { | |
30 static TimeZoneMonitorClient* instance = nullptr; | |
31 if (!instance) | |
32 instance = new TimeZoneMonitorClient(); | |
33 } | |
34 | |
35 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { | |
36 device::mojom::blink::TimeZoneMonitorPtr monitor; | |
37 Platform::current()->interfaceProvider()->getInterface( | |
38 mojo::GetProxy(&monitor)); | |
39 monitor->AddClient(m_binding.CreateInterfacePtrAndBind()); | |
40 } | |
41 | |
42 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} | |
43 | |
44 void TimeZoneMonitorClient::OnTimeZoneChange(const WTF::String& tzInfo) { | |
haraken
2016/10/11 11:45:06
timeZoneInfo
Blink prefers a fully qualified name
leonhsl(Using Gerrit)
2016/10/12 03:55:55
Acknowledged.
| |
45 if (!tzInfo.isEmpty()) { | |
46 icu::TimeZone* zone = icu::TimeZone::createTimeZone( | |
47 icu::UnicodeString::fromUTF8(tzInfo.utf8().data())); | |
48 icu::TimeZone::adoptDefault(zone); | |
49 VLOG(1) << "ICU default timezone is set to " << tzInfo; | |
50 } | |
51 | |
52 NotifyTimezoneChangeOnThisThread(); | |
53 WorkerBackingThread::PostTaskToAllThreads( | |
54 base::Bind(&NotifyTimezoneChangeOnThisThread)); | |
blundell
2016/10/11 11:47:56
What's the WTF equivalent of the base::Bind infras
haraken
2016/10/11 11:50:47
WTF::bind.
leonhsl(Using Gerrit)
2016/10/12 03:55:55
Acknowledged.
| |
55 } | |
56 | |
57 } // namespace blink | |
OLD | NEW |