blob: c696d46f46e9b7ad5daf72db7170bc4b59b31647 [file] [log] [blame]
[email protected]57afedf32014-03-07 10:17:291// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]58edca52012-02-16 21:51:382// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]57afedf32014-03-07 10:17:295#ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_H_
6#define EXTENSIONS_BROWSER_API_API_RESOURCE_H_
[email protected]58edca52012-02-16 21:51:387
8#include "base/basictypes.h"
[email protected]e260cbe2012-03-30 19:53:009#include "base/memory/ref_counted.h"
[email protected]5a0613d32013-06-17 20:06:5310#include "content/public/browser/browser_thread.h"
[email protected]e4452d32013-11-15 23:07:4111#include "extensions/common/extension.h"
[email protected]58edca52012-02-16 21:51:3812
13namespace extensions {
14
[email protected]931186e02012-07-20 01:22:0615// 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.
18class ApiResource {
[email protected]58edca52012-02-16 21:51:3819 public:
[email protected]931186e02012-07-20 01:22:0620 virtual ~ApiResource();
[email protected]58edca52012-02-16 21:51:3821
[email protected]57afedf32014-03-07 10:17:2922 const std::string& owner_extension_id() const { return owner_extension_id_; }
[email protected]09426852012-09-11 22:39:0723
[email protected]a0e8b2c42013-10-22 00:36:1724 // 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]64a3996d2013-08-16 02:05:2627
[email protected]5a0613d32013-06-17 20:06:5328 static const content::BrowserThread::ID kThreadId =
29 content::BrowserThread::IO;
30
[email protected]58edca52012-02-16 21:51:3831 protected:
[email protected]43f8b0a2013-01-09 22:36:5732 explicit ApiResource(const std::string& owner_extension_id);
[email protected]58edca52012-02-16 21:51:3833
[email protected]58edca52012-02-16 21:51:3834 private:
[email protected]43f8b0a2013-01-09 22:36:5735 // The extension that owns this resource.
[email protected]e285f20d2013-10-11 23:05:3736 const std::string owner_extension_id_;
[email protected]09426852012-09-11 22:39:0737
[email protected]931186e02012-07-20 01:22:0638 DISALLOW_COPY_AND_ASSIGN(ApiResource);
[email protected]58edca52012-02-16 21:51:3839};
40
41} // namespace extensions
42
[email protected]57afedf32014-03-07 10:17:2943#endif // EXTENSIONS_BROWSER_API_API_RESOURCE_H_