Home | History | Annotate | Download | only in api
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/memory/ref_counted.h"
     10 #include "chrome/common/extensions/extension.h"
     11 #include "content/public/browser/browser_thread.h"
     12 
     13 namespace extensions {
     14 
     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 {
     19  public:
     20   virtual ~ApiResource();
     21 
     22   const std::string& owner_extension_id() const {
     23     return owner_extension_id_;
     24   }
     25 
     26   static const content::BrowserThread::ID kThreadId =
     27       content::BrowserThread::IO;
     28 
     29  protected:
     30   explicit ApiResource(const std::string& owner_extension_id);
     31 
     32  private:
     33   // The extension that owns this resource.
     34   const std::string& owner_extension_id_;
     35 
     36   DISALLOW_COPY_AND_ASSIGN(ApiResource);
     37 };
     38 
     39 }  // namespace extensions
     40 
     41 #endif  // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
     42