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

Side by Side Diff: third_party/WebKit/Source/modules/battery/BatteryDispatcher.cpp

Issue 1830883002: Add blink::ServiceRegistry and expose it from LocalFrame and Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/battery/BatteryDispatcher.h" 5 #include "modules/battery/BatteryDispatcher.h"
6 6
7 #include "platform/threading/BindForMojo.h" 7 #include "platform/threading/BindForMojo.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "public/platform/ServiceRegistry.h"
9 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
10 #include "wtf/PassOwnPtr.h" 11 #include "wtf/PassOwnPtr.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 BatteryDispatcher& BatteryDispatcher::instance() 15 BatteryDispatcher& BatteryDispatcher::instance()
15 { 16 {
16 DEFINE_STATIC_LOCAL(Persistent<BatteryDispatcher>, batteryDispatcher, (new B atteryDispatcher())); 17 DEFINE_STATIC_LOCAL(Persistent<BatteryDispatcher>, batteryDispatcher, (new B atteryDispatcher()));
17 return *batteryDispatcher; 18 return *batteryDispatcher;
18 } 19 }
(...skipping 27 matching lines...) Expand all
46 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus) 47 void BatteryDispatcher::updateBatteryStatus(const BatteryStatus& batteryStatus)
47 { 48 {
48 m_batteryStatus = batteryStatus; 49 m_batteryStatus = batteryStatus;
49 m_hasLatestData = true; 50 m_hasLatestData = true;
50 notifyControllers(); 51 notifyControllers();
51 } 52 }
52 53
53 void BatteryDispatcher::startListening() 54 void BatteryDispatcher::startListening()
54 { 55 {
55 ASSERT(!m_monitor.is_bound()); 56 ASSERT(!m_monitor.is_bound());
56 Platform::current()->connectToRemoteService(mojo::GetProxy(&m_monitor)); 57 if (!Platform::current()->serviceRegistry())
esprehn 2016/03/31 05:10:43 So one thing we could do is have a static EmptySer
Sam McNally 2016/03/31 09:26:27 Done.
58 return;
59
60 Platform::current()->serviceRegistry()->connectToRemoteService(
61 mojo::GetProxy(&m_monitor));
57 // m_monitor can be null during testing. 62 // m_monitor can be null during testing.
58 if (m_monitor) 63 if (m_monitor)
59 queryNextStatus(); 64 queryNextStatus();
60 } 65 }
61 66
62 void BatteryDispatcher::stopListening() 67 void BatteryDispatcher::stopListening()
63 { 68 {
64 // m_monitor can be null during testing. 69 // m_monitor can be null during testing.
65 if (m_monitor) 70 if (m_monitor)
66 m_monitor.reset(); 71 m_monitor.reset();
67 m_hasLatestData = false; 72 m_hasLatestData = false;
68 } 73 }
69 74
70 } // namespace blink 75 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698