Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
e10s 
@makoto_kato
about:me 
• 
• 
• 
• 
•
•Rust Samurai #4-https://atnd.org/events/54657
Agenda 
•Electrolysis (e10s) ? 
•Firefox OS
•Firefox / Gecko
e10s 
•FirefoxOut-Of-Process Plugin 
•Firefox 3.6 
•FirefoxDRM/CDM(Content Decryption Module) 
•Firefox 3x? 
•FirefoxChrom...
Firefox OS 
•b2g 
•plugin-container 
• 
•APIb2g
Kernel / Gonk 
b2g process 
Plugin- container 
process 
(Apps) 
Plugin- container process 
(Apps) 
Hardware Access 
IPC 
I...
(IPC) 
•ChromiumIPC 
•IPCIPDL 
•IDL
IPDL 
•IDL 
• 
•IPDL 
• 
•
ipdl 
hal/sandbox/PHal.idl 
sync protocol PHal{ 
… 
child: 
NotifyBatteryChange( 
BatteryInformationaBatteryInfo); 
… 
par...
() 
@OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHal.h 
class Msg_NotifyBatteryChange: 
public IPC::Message 
… 
}
() 
@OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHalChild.h 
class /*NS_ABSTRACT_CLASS*/ PHalParent: 
public mozill...
() 
@OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHalChild.h 
class /*NS_ABSTRACT_CLASS*/ PHalChild: 
public mozilla...
template<> 
structParamTraits<mozilla::WidgetGUIEvent> 
{ 
typedefmozilla::WidgetGUIEventparamType; 
static void Write(Mes...
IPC 
•B2g(Chrome) (Content) 
•b2g
•XMLHttpRequsest 
•WebSocket 
•Socket (TCP/UDP) 
•Web Activity 
•Inter App Communication
XMLHttpRequest/ WebSocket 
•
XMLHttpRequest/ WebSocket 
• 
•HTTP 
•Firefox OSDaemon ProcessDaemon Process 
•DRM 
•LocalhostNetwork Activity
Socket API 
•TCP or UDP Socket 
• 
•
TCPSocket () 
varsocket = new navigator.mozTCPSocket.open( 
‘127.0.0.1’, 8888, { binaryType: ‘string’ } ); 
socket.onopen=...
TCP Server Socket 
varsocket = navigator.mozTCPSocket.listen(8888, { binaryType: ‘string’ }); 
Socket.onconnect= function(...
UDP Socket 
varsocket = new UDPSocket(); 
socket.addEventListener(‘message’, function() { 
// 
}) 
socket.send(‘hello’, ‘1...
Web Activity 
•Web IntentAPI (Google Chrome) Firefox OSCounter Proposal
“Web Activities' intent is not to be a clone of Google's Web Intents with some naming and API details changed. Web Activit...
•MozActivity
varactivity = new MozActivity( { 
name: “pick”, 
data: { 
type: “image/jpeg” 
} 
}); 
activity.onsuccess= function() { 
//...
• 
• 
•
{ 
“name”: ‘<Application Name>’, 
“description”: ‘<Application’s description>’, 
“activities”: { 
“view” : { 
“filters”: {...
varregister = navigator.mozRegisterActivityHandler({ 
name: “view”, 
disposition: “inline”, 
filters: { 
type: “image/tiff...
navigator.mozSetMessageHandler(‘activity’, function(request) { 
// 
request.postRequest(…); 
}
Web Activity 
• 
•1:n 
•
Inter-App Communication (IAC) 
•Firefox OS 1.2+ 
•Certified App only 
•Web Activity 
• 
•–Publisher 
• 
•-Subscriber
“connections” { 
“<keyword>” : { 
“handler_path”: “/index.html”, 
“description”: “description”, 
“rules” : { 
“manifestURL...
navigator.mozApps.getSelf().onsuccess= function(ev) { 
varapp = ev.target.result; 
app.connet(‘<keyword>’, rules).then(fun...
navigator.mozSetMessageHandler(‘connection’, 
function(request) { 
varkeyword = request.keyword; 
varport = request.port; ...
Inter App Communication 
•Certified App 
•Certified 
•1:1
•e10sGecko 
•Gecko 
•Firefox OS(Web Activity / Inter- App Communication) e10s 
•APINetwork Activity 
•Gecko 
•XMLHttpReque...
References 
•mozTCPSocket 
•https://developer.mozilla.org/en- US/docs/Web/API/Navigator.mozTCPSocket 
•WebActivities 
•htt...
Upcoming SlideShare
Loading in …5
×

e10sとアプリ間通信

1,319 views

Published on

@ 関西Firefox OS勉強会

Published in: Technology
  • Be the first to comment

e10sとアプリ間通信

  1. 1. e10s @makoto_kato
  2. 2. about:me • • • • •
  3. 3. •Rust Samurai #4-https://atnd.org/events/54657
  4. 4. Agenda •Electrolysis (e10s) ? •Firefox OS
  5. 5. •Firefox / Gecko
  6. 6. e10s •FirefoxOut-Of-Process Plugin •Firefox 3.6 •FirefoxDRM/CDM(Content Decryption Module) •Firefox 3x? •FirefoxChromeContent •(Nightly) •Firefox OS
  7. 7. Firefox OS •b2g •plugin-container • •APIb2g
  8. 8. Kernel / Gonk b2g process Plugin- container process (Apps) Plugin- container process (Apps) Hardware Access IPC IPC
  9. 9. (IPC) •ChromiumIPC •IPCIPDL •IDL
  10. 10. IPDL •IDL • •IPDL • •
  11. 11. ipdl hal/sandbox/PHal.idl sync protocol PHal{ … child: NotifyBatteryChange( BatteryInformationaBatteryInfo); … parent: Vibrate(uint32_t[] pattern, uint64_t[] id, PBrowserbrowser); }
  12. 12. () @OBJDIR@/ipc/ipdl/_ipdlheaders/mozilla/hal_sandbox/PHal.h class Msg_NotifyBatteryChange: public IPC::Message … }
  13. 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. 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. 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); }
  16. 16. IPC •B2g(Chrome) (Content) •b2g
  17. 17. •XMLHttpRequsest •WebSocket •Socket (TCP/UDP) •Web Activity •Inter App Communication
  18. 18. XMLHttpRequest/ WebSocket •
  19. 19. XMLHttpRequest/ WebSocket • •HTTP •Firefox OSDaemon ProcessDaemon Process •DRM •LocalhostNetwork Activity
  20. 20. Socket API •TCP or UDP Socket • •
  21. 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. 22. TCP Server Socket varsocket = navigator.mozTCPSocket.listen(8888, { binaryType: ‘string’ }); Socket.onconnect= function() { // } …
  23. 23. UDP Socket varsocket = new UDPSocket(); socket.addEventListener(‘message’, function() { // }) socket.send(‘hello’, ‘127.0.0.1’, 8888);
  24. 24. Web Activity •Web IntentAPI (Google Chrome) Firefox OSCounter Proposal
  25. 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
  26. 26. •MozActivity
  27. 27. varactivity = new MozActivity( { name: “pick”, data: { type: “image/jpeg” } }); activity.onsuccess= function() { // this.result }
  28. 28. • • •
  29. 29. { “name”: ‘<Application Name>’, “description”: ‘<Application’s description>’, “activities”: { “view” : { “filters”: { “type” : “image/tiff” } } } }
  30. 30. varregister = navigator.mozRegisterActivityHandler({ name: “view”, disposition: “inline”, filters: { type: “image/tiff”; } }
  31. 31. navigator.mozSetMessageHandler(‘activity’, function(request) { // request.postRequest(…); }
  32. 32. Web Activity • •1:n •
  33. 33. Inter-App Communication (IAC) •Firefox OS 1.2+ •Certified App only •Web Activity • •–Publisher • •-Subscriber
  34. 34. “connections” { “<keyword>” : { “handler_path”: “/index.html”, “description”: “description”, “rules” : { “manifestURLs”: “<url>”, … } } }
  35. 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 }); };
  36. 36. navigator.mozSetMessageHandler(‘connection’, function(request) { varkeyword = request.keyword; varport = request.port; port.onmessage= function(evt) { varmessage = evt.data; port.postMessage({ value: “Hello” }); } });
  37. 37. Inter App Communication •Certified App •Certified •1:1
  38. 38. •e10sGecko •Gecko •Firefox OS(Web Activity / Inter- App Communication) e10s •APINetwork Activity •Gecko •XMLHttpRequest/ WebSocket/ Socket API
  39. 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

×