| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ | 7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ |
| 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ | 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ |
| 9 | 9 |
| 10 #include "native_client/src/include/nacl_macros.h" | 10 #include "native_client/src/include/nacl_macros.h" |
| 11 #include "native_client/tests/fake_browser_ppapi/fake_window.h" | 11 #include "ppapi/c/pp_module.h" |
| 12 #include "ppapi/c/ppb_instance.h" | 12 #include "ppapi/c/ppb_instance.h" |
| 13 | 13 |
| 14 namespace fake_browser_ppapi { | 14 namespace fake_browser_ppapi { |
| 15 | 15 |
| 16 class FakeWindow; |
| 16 class Host; | 17 class Host; |
| 17 | 18 |
| 18 // Implements the PPB_Instance interface. | 19 // Implements the PPB_Instance interface. |
| 19 class Instance { | 20 class Instance { |
| 20 public: | 21 public: |
| 21 // You must call set_window to complete initialization. | 22 // You must call set_window to complete initialization. |
| 22 explicit Instance() : window_(NULL) {} | 23 Instance() : instance_id_(0), window_(NULL) {} |
| 23 virtual ~Instance() {} | 24 virtual ~Instance() {} |
| 24 | 25 |
| 25 void set_window(FakeWindow* window) { window_ = window; } | 26 void set_window(FakeWindow* window) { window_ = window; } |
| 26 | 27 |
| 28 void set_instance_id(PP_Instance instance_id) { instance_id_ = instance_id; } |
| 29 PP_Instance instance_id() const { return instance_id_; } |
| 30 |
| 27 // The bindings for the methods invoked by the PPAPI interface. | 31 // The bindings for the methods invoked by the PPAPI interface. |
| 28 virtual PP_Var GetWindowObject(); | 32 virtual PP_Var GetWindowObject(); |
| 29 virtual PP_Var GetOwnerElementObject(); | 33 virtual PP_Var GetOwnerElementObject(); |
| 30 virtual bool BindGraphics(PP_Resource device); | 34 virtual bool BindGraphics(PP_Resource device); |
| 31 virtual bool IsFullFrame(); | 35 virtual bool IsFullFrame(); |
| 32 virtual PP_Var ExecuteScript(PP_Var script, | 36 virtual PP_Var ExecuteScript(PP_Var script, |
| 33 PP_Var* exception); | 37 PP_Var* exception); |
| 34 static const PPB_Instance* GetInterface(); | 38 static const PPB_Instance* GetInterface(); |
| 35 | 39 static Instance* Invalid() { return &kInvalidInstance; } |
| 36 private: | 40 private: |
| 41 static Instance kInvalidInstance; |
| 42 PP_Instance instance_id_; |
| 37 FakeWindow* window_; | 43 FakeWindow* window_; |
| 38 NACL_DISALLOW_COPY_AND_ASSIGN(Instance); | 44 NACL_DISALLOW_COPY_AND_ASSIGN(Instance); |
| 39 }; | 45 }; |
| 40 | 46 |
| 47 // These are made global so that C API functions can access them from any file. |
| 48 // To be implemented by main.cc. |
| 49 PP_Instance TrackInstance(Instance* instance); |
| 50 // Returns Instance::Invalid() on error. |
| 51 Instance* GetInstance(PP_Instance instance_id); |
| 52 |
| 41 } // namespace fake_browser_ppapi | 53 } // namespace fake_browser_ppapi |
| 42 | 54 |
| 43 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ | 55 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_INSTANCE_H_ |
| OLD | NEW |