Chromium Code Reviews| 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 "bindings/core/v8/V8Binding.h" | |
| 8 #include "core/dom/ExecutionContext.h" | |
| 9 #include "core/dom/ExecutionContextTask.h" | |
| 10 #include "core/workers/WorkerThread.h" | |
| 11 #include "public/platform/InterfaceProvider.h" | |
| 12 #include "public/platform/Platform.h" | |
| 13 #include "third_party/icu/source/i18n/unicode/timezone.h" | |
| 14 #include <v8.h> | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 // Notify V8 that the date/time configuration of the system might have changed. | |
| 21 void NotifyTimezoneChange(ExecutionContext* context) { | |
| 22 v8::Isolate* isolate = toIsolate(context); | |
| 23 if (!isolate) | |
|
haraken
2016/10/17 03:59:49
This shouldn't happen.
leonhsl(Using Gerrit)
2016/10/17 07:30:01
Got it, changed to DCHECK(isolate).
| |
| 24 return; | |
| 25 v8::Date::DateTimeConfigurationChangeNotification(isolate); | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 // static | |
| 31 void TimeZoneMonitorClient::Init() { | |
| 32 static TimeZoneMonitorClient* instance = nullptr; | |
| 33 if (!instance) | |
| 34 instance = new TimeZoneMonitorClient(); | |
| 35 } | |
| 36 | |
| 37 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { | |
| 38 device::mojom::blink::TimeZoneMonitorPtr monitor; | |
| 39 Platform::current()->interfaceProvider()->getInterface( | |
| 40 mojo::GetProxy(&monitor)); | |
| 41 monitor->AddClient(m_binding.CreateInterfacePtrAndBind()); | |
| 42 } | |
| 43 | |
| 44 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} | |
| 45 | |
| 46 void TimeZoneMonitorClient::OnTimeZoneChange(const WTF::String& timeZoneInfo) { | |
|
nhiroki
2016/10/13 10:24:12
Is this called only from the main thread?
I'm con
leonhsl(Using Gerrit)
2016/10/14 03:12:00
Yeah mojo binding is thread hostile and the mojo m
nhiroki
2016/10/17 03:56:37
OK, then we can safely access WorkerThread::worker
leonhsl(Using Gerrit)
2016/10/17 07:30:01
Got it.
| |
| 47 if (!timeZoneInfo.isEmpty()) { | |
| 48 icu::TimeZone* zone = icu::TimeZone::createTimeZone( | |
| 49 icu::UnicodeString::fromUTF8(timeZoneInfo.utf8().data())); | |
| 50 icu::TimeZone::adoptDefault(zone); | |
| 51 VLOG(1) << "ICU default timezone is set to " << timeZoneInfo; | |
| 52 } | |
| 53 | |
| 54 NotifyTimezoneChange(nullptr); | |
|
nhiroki
2016/10/13 10:24:12
Does this call make sense?
leonhsl(Using Gerrit)
2016/10/14 03:12:00
This is to notify the V8 isolate for current threa
nhiroki
2016/10/17 03:56:37
Thank you for the explanation. I don't know whethe
haraken
2016/10/17 03:59:49
Can you make NotifyTimezoneChange take an Isolate
leonhsl(Using Gerrit)
2016/10/17 07:30:01
Done and thanks!
| |
| 55 WorkerThread::PostTaskToAllWorkerThreads( | |
| 56 BLINK_FROM_HERE, createCrossThreadTask(&NotifyTimezoneChange)); | |
| 57 } | |
| 58 | |
| 59 } // namespace blink | |
| OLD | NEW |