summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/api_resource.h
blob: 24f1afc0a1d3d95076cc1ca802bb9876791210ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
#define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
#pragma once

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"

namespace extensions {

class APIResourceController;
class APIResourceEventNotifier;

// An APIResource represents something that an extension API manages, such as a
// socket or a serial-port connection.
class APIResource {
 public:
  virtual ~APIResource();

 protected:
  enum APIResourceType {
    SocketResource,
    SerialConnectionResource,
    UsbDeviceResource,
  };
  APIResource(APIResourceType api_resource_type,
              APIResourceEventNotifier* event_notifier);

  APIResourceType api_resource_type() const;
  APIResourceEventNotifier* event_notifier() const;

 private:
  APIResourceType api_resource_type_;
  scoped_refptr<APIResourceEventNotifier> event_notifier_;

  friend class APIResourceController;
  DISALLOW_COPY_AND_ASSIGN(APIResource);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_