Chromium Code Reviews| Index: Source/modules/webusb/NavigatorUSB.cpp |
| diff --git a/Source/modules/webusb/NavigatorUSB.cpp b/Source/modules/webusb/NavigatorUSB.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f97ae28ec74f741fe3881563ebee13837a66fcea |
| --- /dev/null |
| +++ b/Source/modules/webusb/NavigatorUSB.cpp |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "modules/webusb/NavigatorUSB.h" |
| + |
| +#include "core/frame/Navigator.h" |
| +#include "modules/webusb/USB.h" |
| + |
| +namespace blink { |
| + |
| +// static |
|
haraken
2015/07/30 11:26:52
Drop the comment.
Ken Rockot(use gerrit already)
2015/07/30 18:06:54
Done.
|
| +NavigatorUSB& NavigatorUSB::from(Navigator& navigator) |
| +{ |
| + NavigatorUSB* supplement = static_cast<NavigatorUSB*>(HeapSupplement<Navigator>::from(navigator, supplementName())); |
| + if (!supplement) { |
| + supplement = new NavigatorUSB(navigator); |
| + provideTo(navigator, supplementName(), supplement); |
| + } |
| + return *supplement; |
| +} |
| + |
| +// static |
|
haraken
2015/07/30 11:26:51
Drop the comment.
Ken Rockot(use gerrit already)
2015/07/30 18:06:54
Done.
|
| +USB* NavigatorUSB::usb(Navigator& navigator) |
| +{ |
| + return NavigatorUSB::from(navigator).usb(); |
| +} |
| + |
| +USB* NavigatorUSB::usb() |
| +{ |
| + return m_usb.get(); |
|
haraken
2015/07/30 11:26:52
.get() won't be needed.
Ken Rockot(use gerrit already)
2015/07/30 18:06:54
Done.
|
| +} |
| + |
| +DEFINE_TRACE(NavigatorUSB) |
| +{ |
| + visitor->trace(m_usb); |
| + HeapSupplement<Navigator>::trace(visitor); |
| +} |
| + |
| +NavigatorUSB::NavigatorUSB(Navigator& navigator) |
| + : m_usb(USB::create(*navigator.frame())) |
|
haraken
2015/07/30 11:26:52
Is it guaranteed that navigator.frame() returns a
Ken Rockot(use gerrit already)
2015/07/30 18:06:54
That assumption seems to be made in a lot of place
|
| +{ |
| +} |
| + |
| +const char* NavigatorUSB::supplementName() |
| +{ |
| + return "NavigatorUSB"; |
| +} |
| + |
| +} // namespace blink |