From 69ec33dc3ab436a7afa9be6675780165497ece09 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 16 Aug 2015 08:17:01 -0400 Subject: [PATCH] fixed typo in comment + return size of cloud storage - fixed typo as per https://github.com/gorhill/uBlock/commit/7a38cd756d07dedd010d3bc01c42770a33cbb271#commitcomment-12702437 - store size of cloud storage item, I might decide to use this in the UI --- platform/chromium/vapi-background.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 99d1f3ba3..c167b8e29 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -67,10 +67,10 @@ vAPI.storage = chrome.storage.local; // https://developer.chrome.com/extensions/privacy#property-network // 2015-08-12: Wrapped Chrome API in try-catch statements. I had a fluke -// event in which it appeared the Chrome 46 decided to restart uBlock (for +// event in which it appeared Chrome 46 decided to restart uBlock (for // unknown reasons) and again for unknown reasons the browser acted as if // uBlock did not declare the `privacy` permission in its manifest, putting -// uBlock in a bad, non-fonctional state -- because call to `chrome.privacy` +// uBlock in a bad, non-functional state -- because call to `chrome.privacy` // API threw an exception. vAPI.browserSettings = { @@ -1057,18 +1057,21 @@ vAPI.cloud = (function() { }; var push = function(dataKey, data, callback) { - var item = JSON.stringify({ + var bin = { 'source': options.deviceName || options.defaultDeviceName, 'tstamp': Date.now(), - 'data': data - }); + 'data': data, + 'size': 0 + }; + bin.size = JSON.stringify(bin).length; + var item = JSON.stringify(bin); // Chunkify taking into account QUOTA_BYTES_PER_ITEM: // https://developer.chrome.com/extensions/storage#property-sync // "The maximum size (in bytes) of each individual item in sync // "storage, as measured by the JSON stringification of its value // "plus its key length." - var bin = {}; + bin = {}; var chunkCount = Math.ceil(item.length / maxChunkSize); for ( var i = 0; i < chunkCount; i++ ) { bin[dataKey + i.toString()] = item.substr(i * maxChunkSize, maxChunkSize);