SlideShare a Scribd company logo
1 of 23
Download to read offline
Use C++ to Manipulate
mozSettings in Gecko
Mozilla Taiwan
Tommy Kuo [:KuoE0]
kuoe0@mozilla.com
cc-by-sa
mozSettings
Preference system in Gaia
Func1
Func2
Func1
Func4
Func3
mozSettings
get()
get()
set()
set()
get()
Func1
Func2
Func1
Func4
Func3
mozSettings
get()
get()
set()
set()
get()
What would happen if get and
set the same preference in the
same time?
mozSettings
critical section protected with a lock queue
Lock1 Lock2 Lock3 …
(active lock)
mozSettings
Lock1 Lock2 Lock3 Lock4Lock Queue
Func1 / Lock1
Func2 / Lock1
Func1 / Lock1
Func4 / Lock1
Func3 / Lock1
get()
get()
set()
set()
get()
Lock Queue Lock1 Lock2 Lock3 Lock4
(wait Lock1) (wait Lock2) (wait Lock3)
JavaScript
var lock = navigator.mozSettings.createLock();
var setting = lock.get('multiscreen.enabled');
setting.onsuccess = function () {
console.log('multiscreen.enabled: ' +
setting.result['multiscreen.enabled']);
}
setting.onerror = function () {
console.warn('An error occured: ' + setting.error);
}
More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
JavaScript
var lock = navigator.mozSettings.createLock();
var setting = lock.get('multiscreen.enabled');
setting.onsuccess = function () {
console.log('multiscreen.enabled: ' +
setting.result['multiscreen.enabled']);
}
setting.onerror = function () {
console.warn('An error occured: ' + setting.error);
}
Rutern a DOMRequest
More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
JavaScript
var lock = navigator.mozSettings.createLock();
var setting = lock.get('multiscreen.enabled');
setting.onsuccess = function () {
console.log('multiscreen.enabled: ' +
setting.result['multiscreen.enabled']);
}
setting.onerror = function () {
console.warn('An error occured: ' + setting.error);
}
Got result
More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
JavaScript
var lock = navigator.mozSettings.createLock();
var setting = lock.get('multiscreen.enabled');
setting.onsuccess = function () {
console.log('multiscreen.enabled: ' +
setting.result['multiscreen.enabled']);
}
setting.onerror = function () {
console.warn('An error occured: ' + setting.error);
}
Got error
More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
C++
#include "nsISettingsService.h"
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
nsCOMPtr<nsISettingsServiceLock> settingsLock;
settings->CreateLock(nullptr,
getter_AddRefs(settingsLock));
nsRefPtr<GetBoolTask> callback = new GetBoolTask();
settingsLock->Get("multiscreen.enabled", callback);
#include "nsISettingsService.h"
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
nsCOMPtr<nsISettingsServiceLock> settingsLock;
settings->CreateLock(nullptr,
getter_AddRefs(settingsLock));
nsRefPtr<GetBoolTask> callback = new GetBoolTask();
settingsLock->Get("multiscreen.enabled", callback);
C++
Get settings service
#include "nsISettingsService.h"
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
nsCOMPtr<nsISettingsServiceLock> settingsLock;
settings->CreateLock(nullptr,
getter_AddRefs(settingsLock));
nsRefPtr<GetBoolTask> callback = new GetBoolTask();
settingsLock->Get("multiscreen.enabled", callback);
C++
Get settings lock
#include "nsISettingsService.h"
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
nsCOMPtr<nsISettingsServiceLock> settingsLock;
settings->CreateLock(nullptr,
getter_AddRefs(settingsLock));
nsRefPtr<GetBoolTask> callback = new GetBoolTask();
settingsLock->Get("multiscreen.enabled", callback);
C++
Set callback
C++
#include "nsISettingsService.h"
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
nsCOMPtr<nsISettingsServiceLock> settingsLock;
settings->CreateLock(nullptr,
getter_AddRefs(settingsLock));
nsRefPtr<GetBoolTask> callback = new GetBoolTask();
settingsLock->Get("multiscreen.enabled", callback);
What’s this?
nsISettingsServiceCallback
[scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)]
interface nsISettingsServiceCallback : nsISupports
{
void handle(in DOMString aName, in jsval aResult);
void handleError(in DOMString aErrorMessage);
};
the callback object for settings request
nsISettingsServiceCallback
[scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)]
interface nsISettingsServiceCallback : nsISupports
{
void handle(in DOMString aName, in jsval aResult);
void handleError(in DOMString aErrorMessage);
};
the callback object for settings request
onsuccess
nsISettingsServiceCallback
[scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)]
interface nsISettingsServiceCallback : nsISupports
{
void handle(in DOMString aName, in jsval aResult);
void handleError(in DOMString aErrorMessage);
};
the callback object for settings request
onerror
GetBoolTask
class GetBoolTask final : public nsISettingsServiceCallback {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" :
"False");
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString& aMsg)
{
PRINT("error: %s", aMsg);
return NS_OK;
}
protected:
~GetBoolTask() {}
};
inherit from nsISettingsServiceCallback
GetBoolTask
class GetBoolTask final : public nsISettingsServiceCallback {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" :
"False");
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString& aMsg)
{
PRINT("error: %s", aMsg);
return NS_OK;
}
protected:
~GetBoolTask() {}
};
onsuccess
inherit from nsISettingsServiceCallback
GetBoolTask
class GetBoolTask final : public nsISettingsServiceCallback {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" :
"False");
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString& aMsg)
{
PRINT("error: %s", aMsg);
return NS_OK;
}
protected:
~GetBoolTask() {}
};
inherit from nsISettingsServiceCallback
onerror
cc-by-sa
Thanks.

More Related Content

What's hot

Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the pointseanmcq
 
Python opcodes
Python opcodesPython opcodes
Python opcodesalexgolec
 
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014Fantix King 王川
 
The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.10 book - Part 35 of 212The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.10 book - Part 35 of 212Mahmoud Samir Fayed
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency APISeok-joon Yun
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part IAjit Nayak
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in JavaDoug Hawkins
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt IIAjit Nayak
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofitTed Liang
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181Mahmoud Samir Fayed
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesTeerawat Issariyakul
 
The Ring programming language version 1.7 book - Part 84 of 196
The Ring programming language version 1.7 book - Part 84 of 196The Ring programming language version 1.7 book - Part 84 of 196
The Ring programming language version 1.7 book - Part 84 of 196Mahmoud Samir Fayed
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»DataArt
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 

What's hot (20)

Python Async IO Horizon
Python Async IO HorizonPython Async IO Horizon
Python Async IO Horizon
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
 
Python opcodes
Python opcodesPython opcodes
Python opcodes
 
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
About Those Python Async Concurrent Frameworks - Fantix @ OSTC 2014
 
The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.10 book - Part 35 of 212The Ring programming language version 1.10 book - Part 35 of 212
The Ring programming language version 1.10 book - Part 35 of 212
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency API
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
bluespec talk
bluespec talkbluespec talk
bluespec talk
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofit
 
Understanding greenlet
Understanding greenletUnderstanding greenlet
Understanding greenlet
 
The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181The Ring programming language version 1.5.2 book - Part 26 of 181
The Ring programming language version 1.5.2 book - Part 26 of 181
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variables
 
The Ring programming language version 1.7 book - Part 84 of 196
The Ring programming language version 1.7 book - Part 84 of 196The Ring programming language version 1.7 book - Part 84 of 196
The Ring programming language version 1.7 book - Part 84 of 196
 
Network security
Network securityNetwork security
Network security
 
Operating System Engineering
Operating System EngineeringOperating System Engineering
Operating System Engineering
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 

Similar to Use C++ to Manipulate mozSettings in Gecko

The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189Mahmoud Samir Fayed
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
The Ring programming language version 1.5.3 book - Part 71 of 184
The Ring programming language version 1.5.3 book - Part 71 of 184The Ring programming language version 1.5.3 book - Part 71 of 184
The Ring programming language version 1.5.3 book - Part 71 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180Mahmoud Samir Fayed
 
Paver: the build tool you missed
Paver: the build tool you missedPaver: the build tool you missed
Paver: the build tool you missedalmadcz
 
Lightining Talk - Task queue and micro task queues in browser
Lightining Talk - Task queue and micro task queues in browserLightining Talk - Task queue and micro task queues in browser
Lightining Talk - Task queue and micro task queues in browserJitendra Kasaudhan
 
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31Mahmoud Samir Fayed
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebChristian Baranowski
 
The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84Mahmoud Samir Fayed
 

Similar to Use C++ to Manipulate mozSettings in Gecko (20)

The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180
 
Django Celery
Django Celery Django Celery
Django Celery
 
The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196The Ring programming language version 1.7 book - Part 16 of 196
The Ring programming language version 1.7 book - Part 16 of 196
 
The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189The Ring programming language version 1.6 book - Part 15 of 189
The Ring programming language version 1.6 book - Part 15 of 189
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212The Ring programming language version 1.10 book - Part 56 of 212
The Ring programming language version 1.10 book - Part 56 of 212
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
Curator intro
Curator introCurator intro
Curator intro
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
The Ring programming language version 1.5.3 book - Part 71 of 184
The Ring programming language version 1.5.3 book - Part 71 of 184The Ring programming language version 1.5.3 book - Part 71 of 184
The Ring programming language version 1.5.3 book - Part 71 of 184
 
The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212The Ring programming language version 1.10 book - Part 94 of 212
The Ring programming language version 1.10 book - Part 94 of 212
 
The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180
 
Paver: the build tool you missed
Paver: the build tool you missedPaver: the build tool you missed
Paver: the build tool you missed
 
Lightining Talk - Task queue and micro task queues in browser
Lightining Talk - Task queue and micro task queues in browserLightining Talk - Task queue and micro task queues in browser
Lightining Talk - Task queue and micro task queues in browser
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.4.1 book - Part 16 of 31
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184The Ring programming language version 1.5.3 book - Part 78 of 184
The Ring programming language version 1.5.3 book - Part 78 of 184
 
Celery
CeleryCelery
Celery
 
The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.2 book - Part 42 of 84
 

More from Chih-Hsuan Kuo

[Mozilla] content-select
[Mozilla] content-select[Mozilla] content-select
[Mozilla] content-selectChih-Hsuan Kuo
 
在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。Chih-Hsuan Kuo
 
Pocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OSPocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OSChih-Hsuan Kuo
 
面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!Chih-Hsuan Kuo
 
Windows 真的不好用...
Windows 真的不好用...Windows 真的不好用...
Windows 真的不好用...Chih-Hsuan Kuo
 
[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree IsomorphismChih-Hsuan Kuo
 
[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's AlgorithmChih-Hsuan Kuo
 
[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint SetChih-Hsuan Kuo
 
[ACM-ICPC] Efficient Algorithm
[ACM-ICPC] Efficient Algorithm[ACM-ICPC] Efficient Algorithm
[ACM-ICPC] Efficient AlgorithmChih-Hsuan Kuo
 
[ACM-ICPC] Top-down & Bottom-up
[ACM-ICPC] Top-down & Bottom-up[ACM-ICPC] Top-down & Bottom-up
[ACM-ICPC] Top-down & Bottom-upChih-Hsuan Kuo
 

More from Chih-Hsuan Kuo (20)

[Mozilla] content-select
[Mozilla] content-select[Mozilla] content-select
[Mozilla] content-select
 
在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。
 
Pocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OSPocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OS
 
Necko walkthrough
Necko walkthroughNecko walkthrough
Necko walkthrough
 
面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!
 
應徵軟體工程師
應徵軟體工程師應徵軟體工程師
應徵軟體工程師
 
面試心得分享
面試心得分享面試心得分享
面試心得分享
 
Windows 真的不好用...
Windows 真的不好用...Windows 真的不好用...
Windows 真的不好用...
 
Python @Wheel Lab
Python @Wheel LabPython @Wheel Lab
Python @Wheel Lab
 
Introduction to VP8
Introduction to VP8Introduction to VP8
Introduction to VP8
 
Python @NCKU CSIE
Python @NCKU CSIEPython @NCKU CSIE
Python @NCKU CSIE
 
[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism
 
[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm
 
[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set
 
[ACM-ICPC] Traversal
[ACM-ICPC] Traversal[ACM-ICPC] Traversal
[ACM-ICPC] Traversal
 
[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245
 
[ACM-ICPC] Sort
[ACM-ICPC] Sort[ACM-ICPC] Sort
[ACM-ICPC] Sort
 
[ACM-ICPC] Efficient Algorithm
[ACM-ICPC] Efficient Algorithm[ACM-ICPC] Efficient Algorithm
[ACM-ICPC] Efficient Algorithm
 
[ACM-ICPC] Top-down & Bottom-up
[ACM-ICPC] Top-down & Bottom-up[ACM-ICPC] Top-down & Bottom-up
[ACM-ICPC] Top-down & Bottom-up
 
[ACM-ICPC] About I/O
[ACM-ICPC] About I/O[ACM-ICPC] About I/O
[ACM-ICPC] About I/O
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Use C++ to Manipulate mozSettings in Gecko

  • 1. Use C++ to Manipulate mozSettings in Gecko Mozilla Taiwan Tommy Kuo [:KuoE0] kuoe0@mozilla.com cc-by-sa
  • 5. mozSettings critical section protected with a lock queue Lock1 Lock2 Lock3 … (active lock)
  • 6. mozSettings Lock1 Lock2 Lock3 Lock4Lock Queue Func1 / Lock1 Func2 / Lock1 Func1 / Lock1 Func4 / Lock1 Func3 / Lock1 get() get() set() set() get()
  • 7. Lock Queue Lock1 Lock2 Lock3 Lock4 (wait Lock1) (wait Lock2) (wait Lock3)
  • 8. JavaScript var lock = navigator.mozSettings.createLock(); var setting = lock.get('multiscreen.enabled'); setting.onsuccess = function () { console.log('multiscreen.enabled: ' + setting.result['multiscreen.enabled']); } setting.onerror = function () { console.warn('An error occured: ' + setting.error); } More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
  • 9. JavaScript var lock = navigator.mozSettings.createLock(); var setting = lock.get('multiscreen.enabled'); setting.onsuccess = function () { console.log('multiscreen.enabled: ' + setting.result['multiscreen.enabled']); } setting.onerror = function () { console.warn('An error occured: ' + setting.error); } Rutern a DOMRequest More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
  • 10. JavaScript var lock = navigator.mozSettings.createLock(); var setting = lock.get('multiscreen.enabled'); setting.onsuccess = function () { console.log('multiscreen.enabled: ' + setting.result['multiscreen.enabled']); } setting.onerror = function () { console.warn('An error occured: ' + setting.error); } Got result More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
  • 11. JavaScript var lock = navigator.mozSettings.createLock(); var setting = lock.get('multiscreen.enabled'); setting.onsuccess = function () { console.log('multiscreen.enabled: ' + setting.result['multiscreen.enabled']); } setting.onerror = function () { console.warn('An error occured: ' + setting.error); } Got error More detail: https://developer.mozilla.org/en-US/docs/Web/API/Settings_API
  • 12. C++ #include "nsISettingsService.h" nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); nsCOMPtr<nsISettingsServiceLock> settingsLock; settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); nsRefPtr<GetBoolTask> callback = new GetBoolTask(); settingsLock->Get("multiscreen.enabled", callback);
  • 13. #include "nsISettingsService.h" nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); nsCOMPtr<nsISettingsServiceLock> settingsLock; settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); nsRefPtr<GetBoolTask> callback = new GetBoolTask(); settingsLock->Get("multiscreen.enabled", callback); C++ Get settings service
  • 14. #include "nsISettingsService.h" nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); nsCOMPtr<nsISettingsServiceLock> settingsLock; settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); nsRefPtr<GetBoolTask> callback = new GetBoolTask(); settingsLock->Get("multiscreen.enabled", callback); C++ Get settings lock
  • 15. #include "nsISettingsService.h" nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); nsCOMPtr<nsISettingsServiceLock> settingsLock; settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); nsRefPtr<GetBoolTask> callback = new GetBoolTask(); settingsLock->Get("multiscreen.enabled", callback); C++ Set callback
  • 16. C++ #include "nsISettingsService.h" nsCOMPtr<nsISettingsService> settings = do_GetService("@mozilla.org/settingsService;1"); nsCOMPtr<nsISettingsServiceLock> settingsLock; settings->CreateLock(nullptr, getter_AddRefs(settingsLock)); nsRefPtr<GetBoolTask> callback = new GetBoolTask(); settingsLock->Get("multiscreen.enabled", callback); What’s this?
  • 17. nsISettingsServiceCallback [scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)] interface nsISettingsServiceCallback : nsISupports { void handle(in DOMString aName, in jsval aResult); void handleError(in DOMString aErrorMessage); }; the callback object for settings request
  • 18. nsISettingsServiceCallback [scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)] interface nsISettingsServiceCallback : nsISupports { void handle(in DOMString aName, in jsval aResult); void handleError(in DOMString aErrorMessage); }; the callback object for settings request onsuccess
  • 19. nsISettingsServiceCallback [scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)] interface nsISettingsServiceCallback : nsISupports { void handle(in DOMString aName, in jsval aResult); void handleError(in DOMString aErrorMessage); }; the callback object for settings request onerror
  • 20. GetBoolTask class GetBoolTask final : public nsISettingsServiceCallback { public: NS_DECL_ISUPPORTS NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult) { PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" : "False"); return NS_OK; } NS_IMETHOD HandleError(const nsAString& aMsg) { PRINT("error: %s", aMsg); return NS_OK; } protected: ~GetBoolTask() {} }; inherit from nsISettingsServiceCallback
  • 21. GetBoolTask class GetBoolTask final : public nsISettingsServiceCallback { public: NS_DECL_ISUPPORTS NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult) { PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" : "False"); return NS_OK; } NS_IMETHOD HandleError(const nsAString& aMsg) { PRINT("error: %s", aMsg); return NS_OK; } protected: ~GetBoolTask() {} }; onsuccess inherit from nsISettingsServiceCallback
  • 22. GetBoolTask class GetBoolTask final : public nsISettingsServiceCallback { public: NS_DECL_ISUPPORTS NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult) { PRINT("%s: %s", ToNewCString(aName), aResult.toBoolean() ? "True" : "False"); return NS_OK; } NS_IMETHOD HandleError(const nsAString& aMsg) { PRINT("error: %s", aMsg); return NS_OK; } protected: ~GetBoolTask() {} }; inherit from nsISettingsServiceCallback onerror