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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.cpp

Issue 2646383002: Use a new Supplement constructor for (Worker)Navigator supplements (Closed)
Patch Set: temp Created 3 years, 10 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/bluetooth/NavigatorBluetooth.h" 5 #include "modules/bluetooth/NavigatorBluetooth.h"
6 6
7 #include "core/frame/Navigator.h" 7 #include "core/frame/Navigator.h"
8 #include "modules/bluetooth/Bluetooth.h" 8 #include "modules/bluetooth/Bluetooth.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 NavigatorBluetooth& NavigatorBluetooth::from(Navigator& navigator) { 12 NavigatorBluetooth& NavigatorBluetooth::from(Navigator& navigator) {
13 NavigatorBluetooth* supplement = static_cast<NavigatorBluetooth*>( 13 NavigatorBluetooth* supplement = static_cast<NavigatorBluetooth*>(
14 Supplement<Navigator>::from(navigator, supplementName())); 14 Supplement<Navigator>::from(navigator, supplementName()));
15 if (!supplement) { 15 if (!supplement) {
16 supplement = new NavigatorBluetooth(); 16 supplement = new NavigatorBluetooth(navigator);
17 provideTo(navigator, supplementName(), supplement); 17 provideTo(navigator, supplementName(), supplement);
18 } 18 }
19 return *supplement; 19 return *supplement;
20 } 20 }
21 21
22 Bluetooth* NavigatorBluetooth::bluetooth(Navigator& navigator) { 22 Bluetooth* NavigatorBluetooth::bluetooth(Navigator& navigator) {
23 return NavigatorBluetooth::from(navigator).bluetooth(); 23 return NavigatorBluetooth::from(navigator).bluetooth();
24 } 24 }
25 25
26 Bluetooth* NavigatorBluetooth::bluetooth() { 26 Bluetooth* NavigatorBluetooth::bluetooth() {
27 if (!m_bluetooth) 27 if (!m_bluetooth)
28 m_bluetooth = Bluetooth::create(); 28 m_bluetooth = Bluetooth::create();
29 return m_bluetooth.get(); 29 return m_bluetooth.get();
30 } 30 }
31 31
32 DEFINE_TRACE(NavigatorBluetooth) { 32 DEFINE_TRACE(NavigatorBluetooth) {
33 visitor->trace(m_bluetooth); 33 visitor->trace(m_bluetooth);
34 Supplement<Navigator>::trace(visitor); 34 Supplement<Navigator>::trace(visitor);
35 } 35 }
36 36
37 NavigatorBluetooth::NavigatorBluetooth() {} 37 NavigatorBluetooth::NavigatorBluetooth(Navigator& navigator)
38 : Supplement<Navigator>(navigator) {}
38 39
39 const char* NavigatorBluetooth::supplementName() { 40 const char* NavigatorBluetooth::supplementName() {
40 return "NavigatorBluetooth"; 41 return "NavigatorBluetooth";
41 } 42 }
42 43
43 } // namespace blink 44 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698