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

Side by Side Diff: chrome/browser/extensions/api/usb/usb_device_resource.cc

Issue 268713013: Move chrome.usb to //extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 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 (c) 2012 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 "chrome/browser/extensions/api/usb/usb_device_resource.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
12 #include "base/synchronization/lock.h"
13 #include "chrome/common/extensions/api/usb.h"
14 #include "components/usb_service/usb_device_handle.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "extensions/browser/api/api_resource.h"
17
18 using content::BrowserThread;
19 using usb_service::UsbDeviceHandle;
20
21 namespace extensions {
22
23 static base::LazyInstance<
24 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> > >
25 g_factory = LAZY_INSTANCE_INITIALIZER;
26
27 // static
28 template <>
29 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> >*
30 ApiResourceManager<UsbDeviceResource>::GetFactoryInstance() {
31 return g_factory.Pointer();
32 }
33
34 UsbDeviceResource::UsbDeviceResource(const std::string& owner_extension_id,
35 scoped_refptr<UsbDeviceHandle> device)
36 : ApiResource(owner_extension_id), device_(device) {}
37
38 UsbDeviceResource::~UsbDeviceResource() {
39 BrowserThread::PostTask(BrowserThread::FILE,
40 FROM_HERE,
41 base::Bind(&UsbDeviceHandle::Close, device_));
42 }
43
44 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_device_resource.h ('k') | chrome/browser/extensions/api/usb/usb_manual_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698