Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: content/browser/dom_storage/local_storage_context_mojo.h

Issue 2625873004: Delete and try to recreate localstorage database on invalid schema version. (Closed)
Patch Set: 80 cols, and fix typo Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_ 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 24 matching lines...) Expand all
35 ~LocalStorageContextMojo(); 35 ~LocalStorageContextMojo();
36 36
37 void OpenLocalStorage(const url::Origin& origin, 37 void OpenLocalStorage(const url::Origin& origin,
38 mojom::LevelDBWrapperRequest request); 38 mojom::LevelDBWrapperRequest request);
39 void GetStorageUsage(GetStorageUsageCallback callback); 39 void GetStorageUsage(GetStorageUsageCallback callback);
40 void DeleteStorage(const url::Origin& origin); 40 void DeleteStorage(const url::Origin& origin);
41 // Like DeleteStorage(), but also deletes storage for all sub-origins. 41 // Like DeleteStorage(), but also deletes storage for all sub-origins.
42 void DeleteStorageForPhysicalOrigin(const url::Origin& origin); 42 void DeleteStorageForPhysicalOrigin(const url::Origin& origin);
43 void Flush(); 43 void Flush();
44 44
45 void SetDatabaseForTesting(leveldb::mojom::LevelDBDatabasePtr database); 45 leveldb::mojom::LevelDBDatabaseAssociatedRequest DatabaseRequestForTesting();
46 46
47 private: 47 private:
48 // Runs |callback| immediately if already connected to a database, otherwise 48 // Runs |callback| immediately if already connected to a database, otherwise
49 // delays running |callback| untill after a connection has been established. 49 // delays running |callback| untill after a connection has been established.
50 // Initiates connecting to the database if no connection is in progres yet. 50 // Initiates connecting to the database if no connection is in progres yet.
51 void RunWhenConnected(base::OnceClosure callback); 51 void RunWhenConnected(base::OnceClosure callback);
52 52
53 void OnLevelDBWrapperHasNoBindings(const url::Origin& origin); 53 void OnLevelDBWrapperHasNoBindings(const url::Origin& origin);
54 std::vector<leveldb::mojom::BatchedOperationPtr> 54 std::vector<leveldb::mojom::BatchedOperationPtr>
55 OnLevelDBWrapperPrepareToCommit(const url::Origin& origin, 55 OnLevelDBWrapperPrepareToCommit(const url::Origin& origin,
56 const LevelDBWrapperImpl& wrapper); 56 const LevelDBWrapperImpl& wrapper);
57 void OnUserServiceConnectionComplete(); 57 void OnUserServiceConnectionComplete();
58 void OnUserServiceConnectionError(); 58 void OnUserServiceConnectionError();
59 59
60 // Part of our asynchronous directory opening called from OpenLocalStorage(). 60 // Part of our asynchronous directory opening called from RunWhenConnected().
61 void InitiateConnection(bool in_memory_only = false);
61 void OnDirectoryOpened(filesystem::mojom::FileError err); 62 void OnDirectoryOpened(filesystem::mojom::FileError err);
62 void OnDatabaseOpened(leveldb::mojom::DatabaseError status); 63 void OnDatabaseOpened(leveldb::mojom::DatabaseError status);
63 void OnGotDatabaseVersion(leveldb::mojom::DatabaseError status, 64 void OnGotDatabaseVersion(leveldb::mojom::DatabaseError status,
64 const std::vector<uint8_t>& value); 65 const std::vector<uint8_t>& value);
66 void OnConnectionFinished();
67 void DeleteAndRecreateDatabase();
68 void OnDBDestroyed(bool recreate_in_memory,
69 leveldb::mojom::DatabaseError status);
65 70
66 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called 71 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called
67 // directly from that function, or through |on_database_open_callbacks_|. 72 // directly from that function, or through |on_database_open_callbacks_|.
68 void BindLocalStorage(const url::Origin& origin, 73 void BindLocalStorage(const url::Origin& origin,
69 mojom::LevelDBWrapperRequest request); 74 mojom::LevelDBWrapperRequest request);
70 LevelDBWrapperImpl* GetOrCreateDBWrapper(const url::Origin& origin); 75 LevelDBWrapperImpl* GetOrCreateDBWrapper(const url::Origin& origin);
71 76
72 // The (possibly delayed) implementation of GetStorageUsage(). Can be called 77 // The (possibly delayed) implementation of GetStorageUsage(). Can be called
73 // directly from that function, or through |on_database_open_callbacks_|. 78 // directly from that function, or through |on_database_open_callbacks_|.
74 void RetrieveStorageUsage(GetStorageUsageCallback callback); 79 void RetrieveStorageUsage(GetStorageUsageCallback callback);
(...skipping 14 matching lines...) Expand all
89 CONNECTION_FINISHED 94 CONNECTION_FINISHED
90 } connection_state_ = NO_CONNECTION; 95 } connection_state_ = NO_CONNECTION;
91 bool database_initialized_ = false; 96 bool database_initialized_ = false;
92 97
93 std::unique_ptr<service_manager::Connection> file_service_connection_; 98 std::unique_ptr<service_manager::Connection> file_service_connection_;
94 99
95 file::mojom::FileSystemPtr file_system_; 100 file::mojom::FileSystemPtr file_system_;
96 filesystem::mojom::DirectoryPtr directory_; 101 filesystem::mojom::DirectoryPtr directory_;
97 102
98 leveldb::mojom::LevelDBServicePtr leveldb_service_; 103 leveldb::mojom::LevelDBServicePtr leveldb_service_;
99 leveldb::mojom::LevelDBDatabasePtr database_; 104 leveldb::mojom::LevelDBDatabaseAssociatedPtr database_;
105 bool tried_to_recreate_ = false;
100 106
101 std::vector<base::OnceClosure> on_database_opened_callbacks_; 107 std::vector<base::OnceClosure> on_database_opened_callbacks_;
102 108
103 // Maps between an origin and its prefixed LevelDB view. 109 // Maps between an origin and its prefixed LevelDB view.
104 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_; 110 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_;
105 111
106 base::WeakPtrFactory<LocalStorageContextMojo> weak_ptr_factory_; 112 base::WeakPtrFactory<LocalStorageContextMojo> weak_ptr_factory_;
107 }; 113 };
108 114
109 } // namespace content 115 } // namespace content
110 116
111 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_ 117 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_
OLDNEW
« no previous file with comments | « components/leveldb/remote_iterator_unittest.cc ('k') | content/browser/dom_storage/local_storage_context_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698