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 #ifndef EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ |
6 #define EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ | 6 #define EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "device/hid/hid_connection.h" | 12 #include "device/hid/hid_connection.h" |
13 #include "extensions/browser/api/api_resource.h" | 13 #include "extensions/browser/api/api_resource.h" |
14 #include "extensions/browser/api/api_resource_manager.h" | 14 #include "extensions/browser/api/api_resource_manager.h" |
15 | 15 |
16 namespace device { | 16 namespace device { |
17 class HidConnection; | 17 class HidConnection; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 class HidConnectionResource : public ApiResource { | 22 class HidConnectionResource : public ApiResource { |
23 public: | 23 public: |
24 #if defined(OS_MACOSX) | 24 #if defined(OS_WIN) |
25 // Migration from FILE thread to UI thread. OS X gets it first. | 25 // TODO(reillyg): Migrate Windows backend from FILE thread to UI thread. |
| 26 static const content::BrowserThread::ID kThreadId = |
| 27 content::BrowserThread::FILE; |
| 28 #else |
26 static const content::BrowserThread::ID kThreadId = | 29 static const content::BrowserThread::ID kThreadId = |
27 content::BrowserThread::UI; | 30 content::BrowserThread::UI; |
28 #else | |
29 // TODO(reillyg): Migrate Linux/CrOS and Windows as well. | |
30 static const content::BrowserThread::ID kThreadId = | |
31 content::BrowserThread::FILE; | |
32 #endif | 31 #endif |
33 | 32 |
34 HidConnectionResource(const std::string& owner_extension_id, | 33 HidConnectionResource(const std::string& owner_extension_id, |
35 scoped_refptr<device::HidConnection> connection); | 34 scoped_refptr<device::HidConnection> connection); |
36 ~HidConnectionResource() override; | 35 ~HidConnectionResource() override; |
37 | 36 |
38 scoped_refptr<device::HidConnection> connection() const { | 37 scoped_refptr<device::HidConnection> connection() const { |
39 return connection_; | 38 return connection_; |
40 } | 39 } |
41 | 40 |
42 bool IsPersistent() const override; | 41 bool IsPersistent() const override; |
43 | 42 |
44 static const char* service_name() { return "HidConnectionResourceManager"; } | 43 static const char* service_name() { return "HidConnectionResourceManager"; } |
45 | 44 |
46 private: | 45 private: |
47 scoped_refptr<device::HidConnection> connection_; | 46 scoped_refptr<device::HidConnection> connection_; |
48 | 47 |
49 DISALLOW_COPY_AND_ASSIGN(HidConnectionResource); | 48 DISALLOW_COPY_AND_ASSIGN(HidConnectionResource); |
50 }; | 49 }; |
51 | 50 |
52 } // namespace extensions | 51 } // namespace extensions |
53 | 52 |
54 #endif // EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ | 53 #endif // EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_ |
OLD | NEW |