Project Fission/BrowsingContext: Difference between revisions

Add notes on SetWithoutSyncing and Transaction::Commit
(Documentation for SyncedContext and synced fields)
 
(Add notes on SetWithoutSyncing and Transaction::Commit)
Line 81: Line 81:
<syntaxhighlight lang="C++" inline>BrowsingContext</syntaxhighlight> and <syntaxhighlight lang="C++" inline>WindowContext</syntaxhighlight>.
<syntaxhighlight lang="C++" inline>BrowsingContext</syntaxhighlight> and <syntaxhighlight lang="C++" inline>WindowContext</syntaxhighlight>.


Declared fields are default initialized on construction of the owner class. If you need to initialize the fields to something else before first sync, you can use <syntaxhighlight lang="C++" inline>SetWithoutSyncing</syntaxhighlight>.
Whenever a field is synced a number of IPC messages will be sent. To keep this number down it is possible to batch field modifications using the underlying framework on which synced fields are built upon. <syntaxhighlight lang="C++" inline>MOZ_DECL_SYNCED_CONTEXT</syntaxhighlight> defines <syntaxhighlight lang="C++" inline>Transaction</syntaxhighlight> in the owner class which can be used to accomplish this.
Continuing with our contrieved example from before we can do:
<syntaxhighlight lang="C++">
nsresult Foo::SetFirstAndSecond() {
  Tranxaction txn;
  txn.SetFirst(42);
  txn.SetSecond(3.14);
  return txt.Commit();
}
</syntaxhighlight>
(Again note that the returning <syntaxhighlight lang="C++" inline>nsresult</syntaxhighlight> isn't actually in tree yet).
== Browsing Contexts ==
== Browsing Contexts ==


5

edits