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

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

Issue 236203019: Move UsbService to its own component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move usb_service component symbols into usb_service namespace Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_device_resource.h ('k') | chrome/browser/usb/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/extensions/api/usb/usb_device_resource.h" 5 #include "chrome/browser/extensions/api/usb/usb_device_resource.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "chrome/browser/usb/usb_device_handle.h"
14 #include "chrome/common/extensions/api/usb.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" 15 #include "content/public/browser/browser_thread.h"
16 #include "extensions/browser/api/api_resource.h" 16 #include "extensions/browser/api/api_resource.h"
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 using usb_service::UsbDeviceHandle;
19 20
20 namespace extensions { 21 namespace extensions {
21 22
22 static base::LazyInstance< 23 static base::LazyInstance<
23 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> > > 24 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> > >
24 g_factory = LAZY_INSTANCE_INITIALIZER; 25 g_factory = LAZY_INSTANCE_INITIALIZER;
25 26
26 // static 27 // static
27 template <> 28 template <>
28 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> >* 29 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> >*
29 ApiResourceManager<UsbDeviceResource>::GetFactoryInstance() { 30 ApiResourceManager<UsbDeviceResource>::GetFactoryInstance() {
30 return g_factory.Pointer(); 31 return g_factory.Pointer();
31 } 32 }
32 33
33 UsbDeviceResource::UsbDeviceResource(const std::string& owner_extension_id, 34 UsbDeviceResource::UsbDeviceResource(const std::string& owner_extension_id,
34 scoped_refptr<UsbDeviceHandle> device) 35 scoped_refptr<UsbDeviceHandle> device)
35 : ApiResource(owner_extension_id), device_(device) {} 36 : ApiResource(owner_extension_id), device_(device) {}
36 37
37 UsbDeviceResource::~UsbDeviceResource() { 38 UsbDeviceResource::~UsbDeviceResource() {
38 BrowserThread::PostTask(BrowserThread::FILE, 39 BrowserThread::PostTask(BrowserThread::FILE,
39 FROM_HERE, 40 FROM_HERE,
40 base::Bind(&UsbDeviceHandle::Close, device_)); 41 base::Bind(&UsbDeviceHandle::Close, device_));
41 } 42 }
42 43
43 } // namespace extensions 44 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_device_resource.h ('k') | chrome/browser/usb/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698