Handle errors in LevelDBWrapper better

1. If loading from database fails, then set cache mode to contain
   values, since we no longer have database.
2. If commit fails for the first time, the wrapper is deleted and
   recreated by the context. But on subsequent fails, the wrapper is not
   recreated. So, do not unload the values from map till commit is
   successful, otherwise change the cache mode.
3. On commit failure and then a purge, the database will load an old
   version of the data which can cause inconsistency in the values sent
   by renderer and values stored in browser. So, do not report bad
   message in these cases.
4. When the cache mode is only keys, there should be no way for browser
   quota to exceed since there is only one renderer. Report bad message
   in this case.

BUG=744602

Change-Id: I8e60ae0ef6e4c5a9f5ff0c953d6e1b433bc05e1f
Reviewed-on: https://chromium-review.googlesource.com/768249
Commit-Queue: Daniel Murphy <[email protected]>
Reviewed-by: Daniel Murphy <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/master@{#517295}
2 files changed