Commit a228db4f authored by ericu@chromium.org's avatar ericu@chromium.org

Capture snapshots of File metadata whenever we send a File to IDB. This way...

Capture snapshots of File metadata whenever we send a File to IDB.  This way if someone changes a File during a long, slow commit, we won't surprise the user by storing the new version.

Also includes missing error-checking in a test that's sensitive to changes in this area.

See https://codereview.chromium.org/333533002/ for the Chromium code that will check the metadata if you're curious.

BUG=none

Review URL: https://codereview.chromium.org/325383002

git-svn-id: svn://svn.chromium.org/blink/trunk@176538 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d499a4fa
......@@ -66,6 +66,7 @@ function testCursor()
debug("testCursor():");
evalAndLog("transaction = db.transaction('storeName', 'readonly')");
transaction.onerror = unexpectedErrorCallback;
transaction.onabort = unexpectedAbortCallback;
evalAndLog("store = transaction.objectStore('storeName')");
evalAndLog("request = store.openCursor()");
......@@ -107,6 +108,8 @@ function validateResult(variable, validation, onComplete)
evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
evalAndLog("store = transaction.objectStore('storeName')");
evalAndLog("store.put(" + variable + ", '" + keyName + "')");
transaction.onerror = unexpectedErrorCallback;
transaction.onabort = unexpectedAbortCallback;
var readTransactionOnComplete = function (e) {
shouldBeTrue("event.target.result" + validation);
onComplete();
......@@ -123,6 +126,7 @@ function doRead(keyName, onComplete)
evalAndLog("request = store.get('" + keyName + "')");
request.onsuccess = onComplete;
transaction.onerror = unexpectedErrorCallback;
transaction.onabort = unexpectedAbortCallback;
}
if (window.eventSender) {
......
......@@ -1310,7 +1310,7 @@ private:
return handleError(DataCloneError, "A File object has been closed, and could therefore not be cloned.", next);
int blobIndex = -1;
m_blobDataHandles.add(file->uuid(), file->blobDataHandle());
if (appendFileInfo(file->uuid(), file->path(), file->name(), file->type(), &blobIndex)) {
if (appendFileInfo(file, &blobIndex)) {
ASSERT(blobIndex >= 0);
m_writer.writeFileIndex(blobIndex);
} else {
......@@ -1332,7 +1332,7 @@ private:
if (file->hasBeenClosed())
return handleError(DataCloneError, "A File object has been closed, and could therefore not be cloned.", next);
m_blobDataHandles.add(file->uuid(), file->blobDataHandle());
if (appendFileInfo(file->uuid(), file->path(), file->name(), file->type(), &blobIndex)) {
if (appendFileInfo(file, &blobIndex)) {
ASSERT(!i || blobIndex > 0);
ASSERT(blobIndex >= 0);
blobIndices.append(blobIndex);
......@@ -1470,12 +1470,16 @@ private:
return true;
}
bool appendFileInfo(const String& uuid, const String& filePath, const String& fileName, const String& type, int* index)
bool appendFileInfo(const File* file, int* index)
{
if (!m_blobInfo)
return false;
long long size = -1;
double lastModified = invalidFileTime();
file->captureSnapshot(size, lastModified);
*index = m_blobInfo->size();
m_blobInfo->append(blink::WebBlobInfo(uuid, filePath, fileName, type));
m_blobInfo->append(blink::WebBlobInfo(file->uuid(), file->path(), file->name(), file->type(), lastModified, size));
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment