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

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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