Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Side by Side Diff: third_party/WebKit/Source/modules/time_zone_monitor/TimeZoneMonitorClient.cpp

Issue 2460723003: Enable connection to Mojo services from Blink (Closed)
Patch Set: Rebase Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "public/platform/InterfaceProvider.h" 13 #include "platform/ServiceConnector.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "services/device/public/interfaces/constants.mojom-blink.h"
15 #include "third_party/icu/source/i18n/unicode/timezone.h" 16 #include "third_party/icu/source/i18n/unicode/timezone.h"
16 #include <v8.h> 17 #include <v8.h>
17 18
18 namespace blink { 19 namespace blink {
19 20
20 namespace { 21 namespace {
21 22
22 // Notify V8 that the date/time configuration of the system might have changed. 23 // Notify V8 that the date/time configuration of the system might have changed.
23 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) { 24 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) {
24 DCHECK(isolate); 25 DCHECK(isolate);
25 v8::Date::DateTimeConfigurationChangeNotification(isolate); 26 v8::Date::DateTimeConfigurationChangeNotification(isolate);
26 } 27 }
27 28
28 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) { 29 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) {
29 NotifyTimezoneChangeToV8(toIsolate(context)); 30 NotifyTimezoneChangeToV8(toIsolate(context));
30 } 31 }
31 32
32 } // namespace 33 } // namespace
33 34
34 // static 35 // static
35 void TimeZoneMonitorClient::Init() { 36 void TimeZoneMonitorClient::Init() {
36 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ()); 37 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ());
37 38
38 device::mojom::blink::TimeZoneMonitorPtr monitor; 39 device::mojom::blink::TimeZoneMonitorPtr monitor;
39 Platform::current()->interfaceProvider()->getInterface( 40 ServiceConnector::instance().connectToInterface(
40 mojo::MakeRequest(&monitor)); 41 device::mojom::blink::kServiceName, mojo::MakeRequest(&monitor));
41 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind()); 42 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind());
42 } 43 }
43 44
44 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { 45 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) {
45 DCHECK(isMainThread()); 46 DCHECK(isMainThread());
46 } 47 }
47 48
48 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} 49 TimeZoneMonitorClient::~TimeZoneMonitorClient() {}
49 50
50 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) { 51 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) {
(...skipping 16 matching lines...) Expand all
67 // among multiple WorkerThreads. 68 // among multiple WorkerThreads.
68 if (posted.contains(&thread->workerBackingThread())) 69 if (posted.contains(&thread->workerBackingThread()))
69 continue; 70 continue;
70 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask( 71 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask(
71 &NotifyTimezoneChangeOnWorkerThread)); 72 &NotifyTimezoneChangeOnWorkerThread));
72 posted.add(&thread->workerBackingThread()); 73 posted.add(&thread->workerBackingThread());
73 } 74 }
74 } 75 }
75 76
76 } // namespace blink 77 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/time_zone_monitor/DEPS ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698