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

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

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/usb/usb_device_resource.h" 5 #include "extensions/browser/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/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "device/usb/usb_device_handle.h" 15 #include "device/usb/usb_device_handle.h"
16 #include "extensions/browser/api/api_resource.h" 16 #include "extensions/browser/api/api_resource.h"
17 #include "extensions/common/api/usb.h" 17 #include "extensions/common/api/usb.h"
18 18
19 using content::BrowserThread; 19 using content::BrowserThread;
20 using device::UsbDeviceHandle; 20 using device::UsbDeviceHandle;
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 static base::LazyInstance< 24 static base::LazyInstance<BrowserContextKeyedAPIFactory<
25 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> > > 25 ApiResourceManager<UsbDeviceResource>>>::DestructorAtExit g_factory =
26 g_factory = LAZY_INSTANCE_INITIALIZER; 26 LAZY_INSTANCE_INITIALIZER;
27 27
28 // static 28 // static
29 template <> 29 template <>
30 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> >* 30 BrowserContextKeyedAPIFactory<ApiResourceManager<UsbDeviceResource> >*
31 ApiResourceManager<UsbDeviceResource>::GetFactoryInstance() { 31 ApiResourceManager<UsbDeviceResource>::GetFactoryInstance() {
32 return g_factory.Pointer(); 32 return g_factory.Pointer();
33 } 33 }
34 34
35 UsbDeviceResource::UsbDeviceResource(const std::string& owner_extension_id, 35 UsbDeviceResource::UsbDeviceResource(const std::string& owner_extension_id,
36 scoped_refptr<UsbDeviceHandle> device) 36 scoped_refptr<UsbDeviceHandle> device)
37 : ApiResource(owner_extension_id), device_(device) { 37 : ApiResource(owner_extension_id), device_(device) {
38 } 38 }
39 39
40 UsbDeviceResource::~UsbDeviceResource() { 40 UsbDeviceResource::~UsbDeviceResource() {
41 device_->Close(); 41 device_->Close();
42 } 42 }
43 43
44 bool UsbDeviceResource::IsPersistent() const { 44 bool UsbDeviceResource::IsPersistent() const {
45 return false; 45 return false;
46 } 46 }
47 47
48 } // namespace extensions 48 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698