Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/webusb/USBController.h" | |
| 7 | |
| 8 #include "platform/RuntimeEnabledFeatures.h" | |
| 9 #include "public/platform/modules/webusb/WebUSBClient.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 USBController::~USBController() | |
| 14 { | |
| 15 } | |
| 16 | |
| 17 void USBController::provideTo(LocalFrame& frame, WebUSBClient* client) | |
| 18 { | |
| 19 ASSERT(RuntimeEnabledFeatures::webUSBEnabled()); | |
| 20 USBController* controller = new USBController(frame, client); | |
| 21 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPt rWillBeNoop(controller)); | |
| 22 } | |
| 23 | |
| 24 USBController* USBController::from(LocalFrame& frame) | |
|
haraken
2015/07/30 20:18:00
Given that from() shouldn't return a nullptr, the
Ken Rockot(use gerrit already)
2015/07/30 21:10:34
Done.
| |
| 25 { | |
| 26 USBController* controller = static_cast<USBController*>(WillBeHeapSupplement <LocalFrame>::from(frame, supplementName())); | |
| 27 ASSERT(controller); | |
| 28 return controller; | |
| 29 } | |
| 30 | |
| 31 const char* USBController::supplementName() | |
| 32 { | |
| 33 return "USBController"; | |
| 34 } | |
| 35 | |
| 36 USBController::USBController(LocalFrame& frame, WebUSBClient* client) | |
| 37 : LocalFrameLifecycleObserver(&frame) | |
| 38 , m_client(client) | |
| 39 { | |
| 40 } | |
| 41 | |
| 42 void USBController::willDetachFrameHost() | |
| 43 { | |
| 44 m_client = nullptr; | |
| 45 } | |
| 46 | |
| 47 DEFINE_TRACE(USBController) | |
| 48 { | |
| 49 WillBeHeapSupplement<LocalFrame>::trace(visitor); | |
| 50 LocalFrameLifecycleObserver::trace(visitor); | |
| 51 } | |
| 52 | |
| 53 } // namespace blink | |
| OLD | NEW |