WebAPI/DeviceIndexedDB: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
 
(6 intermediate revisions by one other user not shown)
Line 32: Line 32:
   }
   }


The property named "mozDeviceIndexedDB" defines permissions for access control of DeviceIndexedDB databases.  The children of "deviceIndexedDB" are names of databases.  Databases not in the children of a "deviceIndexedDB" of an App can not be accessed by the App.
The property named "mozDeviceIndexedDB" defines permissions for access control of DeviceIndexedDB databases.  The children of "mozDeviceIndexedDB" are names of databases.  Databases not in the children of a "mozDeviceIndexedDB" of an App can not be accessed by the App.


The children of a database is names of data stores.  Data stores not in the children of a database can not be accessed by the App.  The "ObjectStore" property defines whether the App can read or read-write a data store.  If the value of "ObjectStore" is "none", it means the App can not read or write the data store, but it can access indices according setting in "index" child of the data store.
The children of a database is names of data stores.  Data stores not in the children of a database can not be accessed by the App.  The "ObjectStore" property defines whether the App can read or read-write a data store.  If the value of "ObjectStore" is "none", it means the App can not read or write the data store, but it can access indices according setting in "index" child of the data store.
Line 51: Line 51:
Following is an example of finding Apps providing DataCloudStorage services with DeviceIndexedDB as the application chooser.
Following is an example of finding Apps providing DataCloudStorage services with DeviceIndexedDB as the application chooser.


  var request = window.deviceIndexedDB.open("[SystemServices]");
  var request = window.mozDeviceIndexedDB.open("[SystemServices]");
  request.onsuccess = function () {
  request.onsuccess = function () {
   var db = request.result;
   var db = request.result;
Line 70: Line 70:
   name: "My Applicaiton",
   name: "My Applicaiton",
   ......
   ......
   deviceIndexedDB: {
   mozDeviceIndexedDB: {
       "[SystemServices]": {
       "[SystemServices]": {
           "Applications": {
           "Applications": {
Line 85: Line 85:


Since "[SystemServices]" database is implemented by the platform code, writing actions may be forbidden by the implementation according the security model of the data.
Since "[SystemServices]" database is implemented by the platform code, writing actions may be forbidden by the implementation according the security model of the data.
=== Expose Network Statistic of Apps ===
This is an example of exposing network statistics of Apps with DeviceIndexedDB.
var request = window.mozDeviceIndexedDB.open("[SystemServices]");
request.onsuccess = function () {
  var db = request.result;
  var tx = db.transaction("NetworkStatistics");
  var store = tx.objectStore("NetworkStatistics");
  var apps = store.index("apps");
  var statisrequest = apps.get("any-app-id");
  statisrequest.onsuccess = function () {
    var statistic = statisrequest.result;
    showStatisticForApp(statistic);
  }
}
{
  name: "My Applicaiton",
  ......
  mozDeviceIndexedDB: {
      "[SystemServices]": {
          "NetworkStatistics": {
              "ObjectStore": "none",
              "index": {
                  "apps": ["any-app-id"],
              }
          }
      }
  }
}
[[Category:Web APIs]]
Confirmed users
1,340

edits

Navigation menu