blob: 6f3804ac00a3a67ec8da17db532bdd35996b92cc [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// open_and_verify_leveldb_database.pdf was created from this file by
// https://www.code2flow.com/app
OpenOriginState;
switch (Create IDB Directory) {
case Failure:
Histogram(FAILED_DIRECTORY);
return **IOError("Unable to create IndexedDB database path")**;
case Success:
}
Create File path & blob path;
if (File Path is too long) {
Histogram(ORIGIN_TOO_LONG);
return **IOError("File path too long)**;
}
open-loop-start:
Start;
switch(Read corruption info from disk) {
case Corruption Info Exists,
first open attempt:
Histogram(PRIOR_CORRUPTION);
case Corruption Info Exists,
NOT first open attempt:
switch (Destroy the database) {
case Success:
break;
case Failure:
goto open-loop-restart;
}
break;
case No Corruption file found:
}
block Open LevelDB {
|Read free disk space|;
switch (leveldb_env::OpenDB) {
case Status Not OK:{
Histogram(LevelDBOpenErrors);
if (disk space < 100kb) {
goto error;
}
goto open-loop-restart;
}
case Status OK: {
Histogram(LevelDB.OpenTime);
}
}
}
Create LevelDB Scopes;
switch (Initialize LevelDB Scopes) {
case Failure:
Histogram(SCOPES);
goto open-loop-restart;
break;
case Success:
}
block Open LevelDBDatabase {
Create LevelDBDatabase;
switch (Try to read schema) {
case Corruption -
Failure reading schema:
Histogram(CHECKING_SCHEMA);
goto open-loop-restart;
case Corruption -
Schema is unknown:
Histogram(UNKNOWN_SCHEMA);
goto open-loop-restart;
case Success & Valid:
}
}
block Open IndexedDBBackingStore {
Create IndexedDBBackingStore;
switch (Parse schema & metadata) {
case Failure:
Histogram(SETUP_METADATA);
goto open-loop-restart;
break;
case Success:
if (Should we clean blob journal?) {
switch(CleanUpBlobJournal) {
case OK:
goto open-loop-end;
case Not OK:
|Histogram(CLEANUP_JOURNAL)|;
goto open-loop-restart;
}
}
goto open-loop-end;
}
}
open-loop-restart:
|Cleanup from open failure|;
if (Was open failure
due to corruption?) {
Save corruption info to file;
}
if (Has 'Open' been
tried >=2 times?) {
goto error;
}
Go to start;
goto open-loop-start;
open-loop-end:
if (Is database on disk
(instead of in memory)?)
|Histogram(OPEN_SUCCESS)|;
return **SUCCESS AND DONE**;
error:
return **ERROR**;