• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PPAPI_SHARED_IMPL_PPB_DEVICE_REF_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_DEVICE_REF_SHARED_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/thunk/ppb_device_ref_api.h"
15 
16 namespace ppapi {
17 
18 // IF YOU ADD STUFF TO THIS CLASS
19 // ==============================
20 // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h.
21 struct PPAPI_SHARED_EXPORT DeviceRefData {
22   DeviceRefData();
23 
24   bool operator==(const DeviceRefData& other) const {
25     return type == other.type &&
26            name == other.name &&
27            id == other.id;
28   }
29 
30   PP_DeviceType_Dev type;
31   std::string name;
32   std::string id;
33 };
34 
35 class PPAPI_SHARED_EXPORT PPB_DeviceRef_Shared
36     : public Resource,
37       public thunk::PPB_DeviceRef_API {
38  public:
39   PPB_DeviceRef_Shared(ResourceObjectType type,
40                        PP_Instance instance,
41                        const DeviceRefData& data);
42 
43   // Resource overrides.
44   virtual PPB_DeviceRef_API* AsPPB_DeviceRef_API() OVERRIDE;
45 
46   // PPB_DeviceRef_API implementation.
47   virtual const DeviceRefData& GetDeviceRefData() const OVERRIDE;
48   virtual PP_DeviceType_Dev GetType() OVERRIDE;
49   virtual PP_Var GetName() OVERRIDE;
50 
51   static PP_Resource CreateResourceArray(
52       ResourceObjectType type,
53       PP_Instance instance,
54       const std::vector<DeviceRefData>& devices);
55 
56  private:
57   DeviceRefData data_;
58 
59   DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_DeviceRef_Shared);
60 };
61 
62 }  // namespace ppapi
63 
64 #endif  // PPAPI_SHARED_IMPL_PPB_DEVICE_REF_SHARED_H_
65