| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ | 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 // An ApiResource represents something that an extension API manages, such as a | 15 // An ApiResource represents something that an extension API manages, such as a |
| 16 // socket or a serial-port connection. Typically, an ApiResourceManager will | 16 // socket or a serial-port connection. Typically, an ApiResourceManager will |
| 17 // control the lifetime of all ApiResources of a specific derived type. | 17 // control the lifetime of all ApiResources of a specific derived type. |
| 18 class ApiResource { | 18 class ApiResource { |
| 19 public: | 19 public: |
| 20 virtual ~ApiResource(); | 20 virtual ~ApiResource(); |
| 21 | 21 |
| 22 const std::string& owner_extension_id() const { | 22 const std::string& owner_extension_id() const { return owner_extension_id_; } |
| 23 return owner_extension_id_; | |
| 24 } | |
| 25 | 23 |
| 26 // If this method returns |true|, the resource remains open when the | 24 // If this method returns |true|, the resource remains open when the |
| 27 // owning extension is suspended due to inactivity. | 25 // owning extension is suspended due to inactivity. |
| 28 virtual bool IsPersistent() const; | 26 virtual bool IsPersistent() const; |
| 29 | 27 |
| 30 static const content::BrowserThread::ID kThreadId = | 28 static const content::BrowserThread::ID kThreadId = |
| 31 content::BrowserThread::IO; | 29 content::BrowserThread::IO; |
| 32 | 30 |
| 33 protected: | 31 protected: |
| 34 explicit ApiResource(const std::string& owner_extension_id); | 32 explicit ApiResource(const std::string& owner_extension_id); |
| 35 | 33 |
| 36 private: | 34 private: |
| 37 // The extension that owns this resource. | 35 // The extension that owns this resource. |
| 38 const std::string owner_extension_id_; | 36 const std::string owner_extension_id_; |
| 39 | 37 |
| 40 DISALLOW_COPY_AND_ASSIGN(ApiResource); | 38 DISALLOW_COPY_AND_ASSIGN(ApiResource); |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 } // namespace extensions | 41 } // namespace extensions |
| 44 | 42 |
| 45 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ | 43 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_H_ |
| OLD | NEW |