1 // Copyright (c) 2013 Intel Corporation. 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.
5 #ifndef XWALK_EXTENSIONS_COMMON_XWALK_EXTERNAL_INSTANCE_H_
6 #define XWALK_EXTENSIONS_COMMON_XWALK_EXTERNAL_INSTANCE_H_
9 #include "xwalk/extensions/common/xwalk_extension.h"
10 #include "xwalk/extensions/public/XW_Extension.h"
11 #include "xwalk/extensions/public/XW_Extension_SyncMessage.h"
14 namespace extensions {
16 class XWalkExternalAdapter;
17 class XWalkExternalExtension;
19 // XWalkExternalInstance implements the concrete context of execution of an
20 // external extension.
22 // It works together with XWalkExternalAdapter to handle calls from shared
23 // library, and with XWalkExternalExtension to get the appropriate
24 // callbacks. The associated XW_Instance is used to identify this context when
25 // calling the shared library.
26 class XWalkExternalInstance : public XWalkExtensionInstance {
28 XWalkExternalInstance(XWalkExternalExtension* extension,
29 XW_Instance xw_instance);
30 virtual ~XWalkExternalInstance();
33 friend class XWalkExternalAdapter;
35 // XWalkExtensionInstance implementation.
36 virtual void HandleMessage(scoped_ptr<base::Value> msg) OVERRIDE;
37 virtual void HandleSyncMessage(scoped_ptr<base::Value> msg) OVERRIDE;
39 // XW_CoreInterface_1 (from XW_Extension.h) implementation.
40 void CoreSetInstanceData(void* data);
41 void* CoreGetInstanceData();
43 // XW_MessagingInterface_1 (from XW_Extension.h) implementation.
44 void MessagingPostMessage(const char* msg);
46 // XW_Internal_SyncMessagingInterface_1 (from XW_Extension_SyncMessage.h)
48 void SyncMessagingSetSyncReply(const char* reply);
50 XW_Instance xw_instance_;
51 std::string sync_reply_;
52 XWalkExternalExtension* extension_;
54 bool is_handling_sync_msg_;
56 DISALLOW_COPY_AND_ASSIGN(XWalkExternalInstance);
59 } // namespace extensions
62 #endif // XWALK_EXTENSIONS_COMMON_XWALK_EXTERNAL_INSTANCE_H_