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

Side by Side Diff: Source/modules/webusb/NavigatorUSB.cpp

Issue 1262163003: Add WebUSB bindings and client interface [part 1] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
(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/NavigatorUSB.h"
7
8 #include "core/frame/Navigator.h"
9 #include "modules/webusb/USB.h"
10
11 namespace blink {
12
13 // static
haraken 2015/07/30 11:26:52 Drop the comment.
Ken Rockot(use gerrit already) 2015/07/30 18:06:54 Done.
14 NavigatorUSB& NavigatorUSB::from(Navigator& navigator)
15 {
16 NavigatorUSB* supplement = static_cast<NavigatorUSB*>(HeapSupplement<Navigat or>::from(navigator, supplementName()));
17 if (!supplement) {
18 supplement = new NavigatorUSB(navigator);
19 provideTo(navigator, supplementName(), supplement);
20 }
21 return *supplement;
22 }
23
24 // static
haraken 2015/07/30 11:26:51 Drop the comment.
Ken Rockot(use gerrit already) 2015/07/30 18:06:54 Done.
25 USB* NavigatorUSB::usb(Navigator& navigator)
26 {
27 return NavigatorUSB::from(navigator).usb();
28 }
29
30 USB* NavigatorUSB::usb()
31 {
32 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.
33 }
34
35 DEFINE_TRACE(NavigatorUSB)
36 {
37 visitor->trace(m_usb);
38 HeapSupplement<Navigator>::trace(visitor);
39 }
40
41 NavigatorUSB::NavigatorUSB(Navigator& navigator)
42 : 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
43 {
44 }
45
46 const char* NavigatorUSB::supplementName()
47 {
48 return "NavigatorUSB";
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698