OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 const base::FilePath& subdirectory); | 30 const base::FilePath& subdirectory); |
31 ~LocalStorageContextMojo(); | 31 ~LocalStorageContextMojo(); |
32 | 32 |
33 void OpenLocalStorage(const url::Origin& origin, | 33 void OpenLocalStorage(const url::Origin& origin, |
34 mojom::LevelDBWrapperRequest request); | 34 mojom::LevelDBWrapperRequest request); |
35 | 35 |
36 void SetDatabaseForTesting(leveldb::mojom::LevelDBDatabasePtr database); | 36 void SetDatabaseForTesting(leveldb::mojom::LevelDBDatabasePtr database); |
37 | 37 |
38 private: | 38 private: |
39 void OnLevelDBWrapperHasNoBindings(const url::Origin& origin); | 39 void OnLevelDBWrapperHasNoBindings(const url::Origin& origin); |
| 40 std::vector<leveldb::mojom::BatchedOperationPtr> |
| 41 OnLevelDBWrapperPrepareToCommit(); |
40 void OnUserServiceConnectionComplete(); | 42 void OnUserServiceConnectionComplete(); |
41 void OnUserServiceConnectionError(); | 43 void OnUserServiceConnectionError(); |
42 | 44 |
43 // Part of our asynchronous directory opening called from OpenLocalStorage(). | 45 // Part of our asynchronous directory opening called from OpenLocalStorage(). |
44 void OnDirectoryOpened(filesystem::mojom::FileError err); | 46 void OnDirectoryOpened(filesystem::mojom::FileError err); |
45 void OnDatabaseOpened(leveldb::mojom::DatabaseError status); | 47 void OnDatabaseOpened(leveldb::mojom::DatabaseError status); |
46 void OnGotDatabaseVersion(leveldb::mojom::DatabaseError status, | 48 void OnGotDatabaseVersion(leveldb::mojom::DatabaseError status, |
47 const std::vector<uint8_t>& value); | 49 const std::vector<uint8_t>& value); |
48 | 50 |
49 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called | 51 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called |
50 // directly from that function, or through |on_database_open_callbacks_|. | 52 // directly from that function, or through |on_database_open_callbacks_|. |
51 void BindLocalStorage(const url::Origin& origin, | 53 void BindLocalStorage(const url::Origin& origin, |
52 mojom::LevelDBWrapperRequest request); | 54 mojom::LevelDBWrapperRequest request); |
53 | 55 |
54 service_manager::Connector* const connector_; | 56 service_manager::Connector* const connector_; |
55 const base::FilePath subdirectory_; | 57 const base::FilePath subdirectory_; |
56 | 58 |
57 enum ConnectionState { | 59 enum ConnectionState { |
58 NO_CONNECTION, | 60 NO_CONNECTION, |
59 CONNECTION_IN_PROGRESS, | 61 CONNECTION_IN_PROGRESS, |
60 CONNECTION_FINISHED | 62 CONNECTION_FINISHED |
61 } connection_state_ = NO_CONNECTION; | 63 } connection_state_ = NO_CONNECTION; |
| 64 bool database_initialized_ = false; |
62 | 65 |
63 std::unique_ptr<service_manager::Connection> file_service_connection_; | 66 std::unique_ptr<service_manager::Connection> file_service_connection_; |
64 | 67 |
65 file::mojom::FileSystemPtr file_system_; | 68 file::mojom::FileSystemPtr file_system_; |
66 filesystem::mojom::DirectoryPtr directory_; | 69 filesystem::mojom::DirectoryPtr directory_; |
67 | 70 |
68 leveldb::mojom::LevelDBServicePtr leveldb_service_; | 71 leveldb::mojom::LevelDBServicePtr leveldb_service_; |
69 leveldb::mojom::LevelDBDatabasePtr database_; | 72 leveldb::mojom::LevelDBDatabasePtr database_; |
70 | 73 |
71 std::vector<base::Closure> on_database_opened_callbacks_; | 74 std::vector<base::OnceClosure> on_database_opened_callbacks_; |
72 | 75 |
73 // Maps between an origin and its prefixed LevelDB view. | 76 // Maps between an origin and its prefixed LevelDB view. |
74 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_; | 77 std::map<url::Origin, std::unique_ptr<LevelDBWrapperImpl>> level_db_wrappers_; |
75 | 78 |
76 base::WeakPtrFactory<LocalStorageContextMojo> weak_ptr_factory_; | 79 base::WeakPtrFactory<LocalStorageContextMojo> weak_ptr_factory_; |
77 }; | 80 }; |
78 | 81 |
79 } // namespace content | 82 } // namespace content |
80 | 83 |
81 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_ | 84 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_CONTEXT_MOJO_H_ |
OLD | NEW |