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

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: Fix build Created 4 years, 1 month 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 "public/platform/InterfaceProvider.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "services/device/public/cpp/constants.h"
16 #include "services/service_manager/public/cpp/connector.h"
15 #include "third_party/icu/source/i18n/unicode/timezone.h" 17 #include "third_party/icu/source/i18n/unicode/timezone.h"
16 #include <v8.h> 18 #include <v8.h>
17 19
18 namespace blink { 20 namespace blink {
19 21
20 namespace { 22 namespace {
21 23
22 // Notify V8 that the date/time configuration of the system might have changed. 24 // Notify V8 that the date/time configuration of the system might have changed.
23 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) { 25 void NotifyTimezoneChangeToV8(v8::Isolate* isolate) {
24 DCHECK(isolate); 26 DCHECK(isolate);
25 v8::Date::DateTimeConfigurationChangeNotification(isolate); 27 v8::Date::DateTimeConfigurationChangeNotification(isolate);
26 } 28 }
27 29
28 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) { 30 void NotifyTimezoneChangeOnWorkerThread(ExecutionContext* context) {
29 NotifyTimezoneChangeToV8(toIsolate(context)); 31 NotifyTimezoneChangeToV8(toIsolate(context));
30 } 32 }
31 33
32 } // namespace 34 } // namespace
33 35
34 // static 36 // static
35 void TimeZoneMonitorClient::Init() { 37 void TimeZoneMonitorClient::Init() {
38 if (!Platform::current()->serviceConnector())
39 return;
40
36 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ()); 41 DEFINE_STATIC_LOCAL(TimeZoneMonitorClient, instance, ());
37 42
38 device::mojom::blink::TimeZoneMonitorPtr monitor; 43 device::mojom::blink::TimeZoneMonitorPtr monitor;
39 Platform::current()->interfaceProvider()->getInterface( 44 std::unique_ptr<service_manager::Connection> deviceService =
40 mojo::GetProxy(&monitor)); 45 Platform::current()->serviceConnector()->Connect(
46 device::kDeviceServiceName);
47 deviceService->GetInterface(mojo::GetProxy(&monitor));
41 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind()); 48 monitor->AddClient(instance.m_binding.CreateInterfacePtrAndBind());
42 } 49 }
43 50
44 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) { 51 TimeZoneMonitorClient::TimeZoneMonitorClient() : m_binding(this) {
45 DCHECK(isMainThread()); 52 DCHECK(isMainThread());
46 } 53 }
47 54
48 TimeZoneMonitorClient::~TimeZoneMonitorClient() {} 55 TimeZoneMonitorClient::~TimeZoneMonitorClient() {}
49 56
50 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) { 57 void TimeZoneMonitorClient::OnTimeZoneChange(const String& timeZoneInfo) {
(...skipping 16 matching lines...) Expand all
67 // among multiple WorkerThreads. 74 // among multiple WorkerThreads.
68 if (posted.contains(&thread->workerBackingThread())) 75 if (posted.contains(&thread->workerBackingThread()))
69 continue; 76 continue;
70 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask( 77 thread->postTask(BLINK_FROM_HERE, createCrossThreadTask(
71 &NotifyTimezoneChangeOnWorkerThread)); 78 &NotifyTimezoneChangeOnWorkerThread));
72 posted.add(&thread->workerBackingThread()); 79 posted.add(&thread->workerBackingThread());
73 } 80 }
74 } 81 }
75 82
76 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698