Contenu connexe Similaire à e10sとアプリ間通信 (20) e10sとアプリ間通信8. Kernel / Gonk
b2g process
Plugin- container
process
(Apps)
Plugin- container process
(Apps)
Hardware Access
IPC
IPC 11. ipdl
hal/sandbox/PHal.idl
sync protocol PHal{
…
child:
NotifyBatteryChange(
BatteryInformationaBatteryInfo);
…
parent:
Vibrate(uint32_t[] pattern, uint64_t[] id,
PBrowserbrowser);
} 13. ()
@OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHalChild.h
class /*NS_ABSTRACT_CLASS*/ PHalParent:
public mozilla::ipc::IProtocol,
protected mozilla::ipc::IProtocolManager<mozilla::ipc::IProtocol>
{
…
virtual bool
RecvVibrate(
constnsTArray<uint32_t>& pattern,
constnsTArray<uint64_t>& id,
PBrowserParent* browser) = 0;
…
bool
SendNotifyBatteryChange(constBatteryInformation& aBatteryInfo) NS_WARN_UNUSED_RESULT; 14. ()
@OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHalChild.h
class /*NS_ABSTRACT_CLASS*/ PHalChild:
public mozilla::ipc::IProtocol,
protected mozilla::ipc::IProtocolManager<mozilla::ipc::IProtocol>
{
…
virtual bool
RecvNotifyBatteryChange(constBatteryInformation& aBatteryInfo) = 0;
…
bool
SendVibrate(
constnsTArray<uint32_t>& pattern,
constnsTArray<uint64_t>& id,
PBrowserChild* browser); 15. template<>
structParamTraits<mozilla::WidgetGUIEvent>
{
typedefmozilla::WidgetGUIEventparamType;
static void Write(Message* aMsg, constparamType& aParam)
{
WriteParam(aMsg, static_cast<mozilla::WidgetEvent>(aParam));
WriteParam(aMsg, aParam.mPluginEvent.mBuffer);
}
static boolRead(constMessage* aMsg, void** aIter,
paramType* aResult)
{
return ReadParam(aMsg, aIter,
static_cast<mozilla::WidgetEvent*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->mPluginEvent.mBuffer);
} 21. TCPSocket ()
varsocket = new navigator.mozTCPSocket.open(
‘127.0.0.1’, 8888, { binaryType: ‘string’ } );
socket.onopen= function() {
};
socket.ondata= function(msg) {
//
};
…
socket.send(‘hello’); 22. TCP Server Socket
varsocket = navigator.mozTCPSocket.listen(8888, { binaryType: ‘string’ });
Socket.onconnect= function() {
//
}
… 23. UDP Socket
varsocket = new UDPSocket();
socket.addEventListener(‘message’, function() {
//
})
socket.send(‘hello’, ‘127.0.0.1’, 8888); 25. “Web Activities' intent is not to be a clone of Google's Web Intents with some naming and API details changed. Web Activities aim to be a simple API trying to solve a very clear set of use cases.” http://lists.w3.org/Archives/Public/public-web- intents/2012Jun/0061.html 27. varactivity = new MozActivity( {
name: “pick”,
data: {
type: “image/jpeg”
}
});
activity.onsuccess= function() {
// this.result
} 29. {
“name”: ‘<Application Name>’,
“description”: ‘<Application’s description>’,
“activities”: {
“view” : {
“filters”: {
“type” : “image/tiff”
}
}
}
} 34. “connections” {
“<keyword>” : {
“handler_path”: “/index.html”,
“description”: “description”,
“rules” : {
“manifestURLs”: “<url>”,
…
}
}
} 35. navigator.mozApps.getSelf().onsuccess= function(ev) {
varapp = ev.target.result;
app.connet(‘<keyword>’, rules).then(function(ports) {
// connected
ports.forEach(function(port) {
port.onmessage= function(evt) {
// received data
});
port.postMessage({ value: ‘hello’ });
}
}, function(reason) {
// reject
});
}; 38. •e10sGecko
•Gecko
•Firefox OS(Web Activity / Inter- App Communication) e10s
•APINetwork Activity
•Gecko
•XMLHttpRequest/ WebSocket/ Socket API 39. References
•mozTCPSocket
•https://developer.mozilla.org/en- US/docs/Web/API/Navigator.mozTCPSocket
•WebActivities
•https://developer.mozilla.org/en- US/docs/Web/API/Web_Activities
•Inter App Communication
•https://wiki.mozilla.org/WebAPI/Inter_App_Communication
•https://bugzilla.mozilla.org/show_bug.cgi?id=907068