[email protected] | 57afedf3 | 2014-03-07 10:17:29 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 57afedf3 | 2014-03-07 10:17:29 | [diff] [blame] | 5 | #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_H_ |
6 | #define EXTENSIONS_BROWSER_API_API_RESOURCE_H_ | ||||
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 7 | |
8 | #include "base/basictypes.h" | ||||
[email protected] | e260cbe | 2012-03-30 19:53:00 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
[email protected] | 5a0613d3 | 2013-06-17 20:06:53 | [diff] [blame] | 10 | #include "content/public/browser/browser_thread.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 11 | #include "extensions/common/extension.h" |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 12 | |
13 | namespace extensions { | ||||
14 | |||||
[email protected] | 931186e0 | 2012-07-20 01:22:06 | [diff] [blame] | 15 | // An ApiResource represents something that an extension API manages, such as a |
16 | // socket or a serial-port connection. Typically, an ApiResourceManager will | ||||
17 | // control the lifetime of all ApiResources of a specific derived type. | ||||
18 | class ApiResource { | ||||
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 19 | public: |
[email protected] | 931186e0 | 2012-07-20 01:22:06 | [diff] [blame] | 20 | virtual ~ApiResource(); |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 21 | |
[email protected] | 57afedf3 | 2014-03-07 10:17:29 | [diff] [blame] | 22 | const std::string& owner_extension_id() const { return owner_extension_id_; } |
[email protected] | 0942685 | 2012-09-11 22:39:07 | [diff] [blame] | 23 | |
[email protected] | a0e8b2c4 | 2013-10-22 00:36:17 | [diff] [blame] | 24 | // If this method returns |true|, the resource remains open when the |
25 | // owning extension is suspended due to inactivity. | ||||
26 | virtual bool IsPersistent() const; | ||||
[email protected] | 64a3996d | 2013-08-16 02:05:26 | [diff] [blame] | 27 | |
[email protected] | 5a0613d3 | 2013-06-17 20:06:53 | [diff] [blame] | 28 | static const content::BrowserThread::ID kThreadId = |
29 | content::BrowserThread::IO; | ||||
30 | |||||
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 31 | protected: |
[email protected] | 43f8b0a | 2013-01-09 22:36:57 | [diff] [blame] | 32 | explicit ApiResource(const std::string& owner_extension_id); |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 33 | |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 34 | private: |
[email protected] | 43f8b0a | 2013-01-09 22:36:57 | [diff] [blame] | 35 | // The extension that owns this resource. |
[email protected] | e285f20d | 2013-10-11 23:05:37 | [diff] [blame] | 36 | const std::string owner_extension_id_; |
[email protected] | 0942685 | 2012-09-11 22:39:07 | [diff] [blame] | 37 | |
[email protected] | 931186e0 | 2012-07-20 01:22:06 | [diff] [blame] | 38 | DISALLOW_COPY_AND_ASSIGN(ApiResource); |
[email protected] | 58edca5 | 2012-02-16 21:51:38 | [diff] [blame] | 39 | }; |
40 | |||||
41 | } // namespace extensions | ||||
42 | |||||
[email protected] | 57afedf3 | 2014-03-07 10:17:29 | [diff] [blame] | 43 | #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_H_ |