| OLD | NEW |
| 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 { | 13 { |
| 14 NavigatorBluetooth* supplement = static_cast<NavigatorBluetooth*>(HeapSupple
ment<Navigator>::from(navigator, supplementName())); | 14 NavigatorBluetooth* supplement = static_cast<NavigatorBluetooth*>(Supplement
<Navigator>::from(navigator, supplementName())); |
| 15 if (!supplement) { | 15 if (!supplement) { |
| 16 supplement = new NavigatorBluetooth(); | 16 supplement = new NavigatorBluetooth(); |
| 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 { | 23 { |
| 24 return NavigatorBluetooth::from(navigator).bluetooth(); | 24 return NavigatorBluetooth::from(navigator).bluetooth(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 Bluetooth* NavigatorBluetooth::bluetooth() | 27 Bluetooth* NavigatorBluetooth::bluetooth() |
| 28 { | 28 { |
| 29 if (!m_bluetooth) | 29 if (!m_bluetooth) |
| 30 m_bluetooth = Bluetooth::create(); | 30 m_bluetooth = Bluetooth::create(); |
| 31 return m_bluetooth.get(); | 31 return m_bluetooth.get(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 DEFINE_TRACE(NavigatorBluetooth) | 34 DEFINE_TRACE(NavigatorBluetooth) |
| 35 { | 35 { |
| 36 visitor->trace(m_bluetooth); | 36 visitor->trace(m_bluetooth); |
| 37 HeapSupplement<Navigator>::trace(visitor); | 37 Supplement<Navigator>::trace(visitor); |
| 38 } | 38 } |
| 39 | 39 |
| 40 NavigatorBluetooth::NavigatorBluetooth() | 40 NavigatorBluetooth::NavigatorBluetooth() |
| 41 { | 41 { |
| 42 } | 42 } |
| 43 | 43 |
| 44 const char* NavigatorBluetooth::supplementName() | 44 const char* NavigatorBluetooth::supplementName() |
| 45 { | 45 { |
| 46 return "NavigatorBluetooth"; | 46 return "NavigatorBluetooth"; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace blink | 49 } // namespace blink |
| OLD | NEW |