OLD | NEW |
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/hid/hid_connection_resource.h" | 5 #include "extensions/browser/api/hid/hid_connection_resource.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "device/hid/hid_connection.h" | 11 #include "device/hid/hid_connection.h" |
12 #include "extensions/browser/api/api_resource_manager.h" | 12 #include "extensions/browser/api/api_resource_manager.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 static base::LazyInstance< | 16 static base::LazyInstance<BrowserContextKeyedAPIFactory< |
17 BrowserContextKeyedAPIFactory<ApiResourceManager<HidConnectionResource> > > | 17 ApiResourceManager<HidConnectionResource>>>::DestructorAtExit g_factory = |
18 g_factory = LAZY_INSTANCE_INITIALIZER; | 18 LAZY_INSTANCE_INITIALIZER; |
19 | 19 |
20 // static | 20 // static |
21 template <> | 21 template <> |
22 BrowserContextKeyedAPIFactory<ApiResourceManager<HidConnectionResource> >* | 22 BrowserContextKeyedAPIFactory<ApiResourceManager<HidConnectionResource> >* |
23 ApiResourceManager<HidConnectionResource>::GetFactoryInstance() { | 23 ApiResourceManager<HidConnectionResource>::GetFactoryInstance() { |
24 return &g_factory.Get(); | 24 return &g_factory.Get(); |
25 } | 25 } |
26 | 26 |
27 HidConnectionResource::HidConnectionResource( | 27 HidConnectionResource::HidConnectionResource( |
28 const std::string& owner_extension_id, | 28 const std::string& owner_extension_id, |
29 scoped_refptr<device::HidConnection> connection) | 29 scoped_refptr<device::HidConnection> connection) |
30 : ApiResource(owner_extension_id), connection_(connection) {} | 30 : ApiResource(owner_extension_id), connection_(connection) {} |
31 | 31 |
32 HidConnectionResource::~HidConnectionResource() { | 32 HidConnectionResource::~HidConnectionResource() { |
33 connection_->Close(); | 33 connection_->Close(); |
34 } | 34 } |
35 | 35 |
36 bool HidConnectionResource::IsPersistent() const { | 36 bool HidConnectionResource::IsPersistent() const { |
37 return false; | 37 return false; |
38 } | 38 } |
39 | 39 |
40 } // namespace extensions | 40 } // namespace extensions |
OLD | NEW |