| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webusb/USBController.h" | 5 #include "modules/webusb/USBController.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "public/platform/modules/webusb/WebUSBClient.h" | 8 #include "public/platform/modules/webusb/WebUSBClient.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 USBController::~USBController() | 12 USBController::~USBController() |
| 13 { | 13 { |
| 14 } | 14 } |
| 15 | 15 |
| 16 void USBController::provideTo(LocalFrame& frame, WebUSBClient* client) | 16 void USBController::provideTo(LocalFrame& frame, WebUSBClient* client) |
| 17 { | 17 { |
| 18 ASSERT(RuntimeEnabledFeatures::webUSBEnabled()); | 18 ASSERT(RuntimeEnabledFeatures::webUSBEnabled()); |
| 19 USBController* controller = new USBController(frame, client); | 19 USBController* controller = new USBController(frame, client); |
| 20 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPt
rWillBeNoop(controller)); | 20 HeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPtrWillB
eNoop(controller)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 USBController& USBController::from(LocalFrame& frame) | 23 USBController& USBController::from(LocalFrame& frame) |
| 24 { | 24 { |
| 25 USBController* controller = static_cast<USBController*>(WillBeHeapSupplement
<LocalFrame>::from(frame, supplementName())); | 25 USBController* controller = static_cast<USBController*>(HeapSupplement<Local
Frame>::from(frame, supplementName())); |
| 26 ASSERT(controller); | 26 ASSERT(controller); |
| 27 return *controller; | 27 return *controller; |
| 28 } | 28 } |
| 29 | 29 |
| 30 const char* USBController::supplementName() | 30 const char* USBController::supplementName() |
| 31 { | 31 { |
| 32 return "USBController"; | 32 return "USBController"; |
| 33 } | 33 } |
| 34 | 34 |
| 35 USBController::USBController(LocalFrame& frame, WebUSBClient* client) | 35 USBController::USBController(LocalFrame& frame, WebUSBClient* client) |
| 36 : LocalFrameLifecycleObserver(&frame) | 36 : LocalFrameLifecycleObserver(&frame) |
| 37 , m_client(client) | 37 , m_client(client) |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void USBController::willDetachFrameHost() | 41 void USBController::willDetachFrameHost() |
| 42 { | 42 { |
| 43 m_client = nullptr; | 43 m_client = nullptr; |
| 44 } | 44 } |
| 45 | 45 |
| 46 DEFINE_TRACE(USBController) | 46 DEFINE_TRACE(USBController) |
| 47 { | 47 { |
| 48 WillBeHeapSupplement<LocalFrame>::trace(visitor); | 48 HeapSupplement<LocalFrame>::trace(visitor); |
| 49 LocalFrameLifecycleObserver::trace(visitor); | 49 LocalFrameLifecycleObserver::trace(visitor); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |