- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / tests / nacl_io_test / fake_var_interface.h
1 // Copyright (c) 2013 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 LIBRARIES_NACL_IO_TEST_FAKE_VAR_INTERFACE_H_
6 #define LIBRARIES_NACL_IO_TEST_FAKE_VAR_INTERFACE_H_
7
8 #include <map>
9 #include <string>
10
11 #include <ppapi/c/pp_var.h>
12
13 #include "nacl_io/pepper_interface.h"
14 #include "sdk_util/macros.h"
15
16 class FakeVarInterface : public nacl_io::VarInterface {
17  public:
18   FakeVarInterface();
19   ~FakeVarInterface();
20
21   virtual void AddRef(PP_Var var);
22   virtual void Release(PP_Var var);
23   virtual PP_Var VarFromUtf8(const char* data, uint32_t len);
24   virtual const char* VarToUtf8(PP_Var var, uint32_t* out_len);
25
26  private:
27   typedef uint64_t Id;
28
29   struct FakeStringVar {
30     std::string value;
31     int32_t ref_count;
32   };
33
34   typedef std::map<Id, FakeStringVar> VarMap;
35   Id next_id_;
36   VarMap var_map_;
37
38   DISALLOW_COPY_AND_ASSIGN(FakeVarInterface);
39 };
40
41 #endif  // LIBRARIES_NACL_IO_TEST_FAKE_VAR_INTERFACE_H_