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

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

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. (Mostly removing BrowserContext knowlege.) Created 4 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_DOM_STORAGE_CONTEXT_WRAPPER_H_ 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "components/filesystem/public/interfaces/directory.mojom.h"
15 #include "components/filesystem/public/interfaces/file_system.mojom.h"
16 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
17 #include "components/profile_service/public/interfaces/profile.mojom.h"
13 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
14 #include "content/common/storage_partition_service.mojom.h" 19 #include "content/common/storage_partition_service.mojom.h"
15 #include "content/public/browser/dom_storage_context.h" 20 #include "content/public/browser/dom_storage_context.h"
16 21
17 namespace base { 22 namespace base {
18 class FilePath; 23 class FilePath;
19 } 24 }
20 25
21 namespace storage { 26 namespace storage {
22 class SpecialStoragePolicy; 27 class SpecialStoragePolicy;
23 } 28 }
24 29
25 namespace content { 30 namespace content {
26 31
27 class DOMStorageContextImpl; 32 class DOMStorageContextImpl;
28 class LevelDBWrapperImpl; 33 class LevelDBWrapperImpl;
34 class MojoAppConnection;
29 35
30 // This is owned by Storage Partition and encapsulates all its dom storage 36 // This is owned by Storage Partition and encapsulates all its dom storage
31 // state. 37 // state.
32 class CONTENT_EXPORT DOMStorageContextWrapper : 38 class CONTENT_EXPORT DOMStorageContextWrapper :
33 NON_EXPORTED_BASE(public DOMStorageContext), 39 NON_EXPORTED_BASE(public DOMStorageContext),
34 public base::RefCountedThreadSafe<DOMStorageContextWrapper> { 40 public base::RefCountedThreadSafe<DOMStorageContextWrapper> {
35 public: 41 public:
36 // If |data_path| is empty, nothing will be saved to disk. 42 // If |data_path| is empty, nothing will be saved to disk.
37 DOMStorageContextWrapper( 43 DOMStorageContextWrapper(
44 uint32_t mojo_user_id,
38 const base::FilePath& data_path, 45 const base::FilePath& data_path,
39 storage::SpecialStoragePolicy* special_storage_policy); 46 storage::SpecialStoragePolicy* special_storage_policy);
40 47
41 // DOMStorageContext implementation. 48 // DOMStorageContext implementation.
42 void GetLocalStorageUsage( 49 void GetLocalStorageUsage(
43 const GetLocalStorageUsageCallback& callback) override; 50 const GetLocalStorageUsageCallback& callback) override;
44 void GetSessionStorageUsage( 51 void GetSessionStorageUsage(
45 const GetSessionStorageUsageCallback& callback) override; 52 const GetSessionStorageUsageCallback& callback) override;
46 void DeleteLocalStorage(const GURL& origin) override; 53 void DeleteLocalStorage(const GURL& origin) override;
47 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override; 54 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override;
(...skipping 21 matching lines...) Expand all
69 private: 76 private:
70 friend class DOMStorageMessageFilter; // for access to context() 77 friend class DOMStorageMessageFilter; // for access to context()
71 friend class SessionStorageNamespaceImpl; // ditto 78 friend class SessionStorageNamespaceImpl; // ditto
72 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>; 79 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>;
73 80
74 ~DOMStorageContextWrapper() override; 81 ~DOMStorageContextWrapper() override;
75 DOMStorageContextImpl* context() const { return context_.get(); } 82 DOMStorageContextImpl* context() const { return context_.get(); }
76 83
77 void LevelDBWrapperImplHasNoBindings(const std::string& origin); 84 void LevelDBWrapperImplHasNoBindings(const std::string& origin);
78 85
86 // Part of our asynchronous directory opening called from OpenLocalStorage().
87 void OnDirectoryOpened(filesystem::FileError err);
88 void OnDatabaseOpened(leveldb::DatabaseError status);
89
90 void OnCrudWritten(leveldb::DatabaseError status);
91
92 // The (possibly delayed) implementation of OpenLocalStorage(). Can be called
93 // directly from that function, or through |on_database_open_callbacks_|.
94 void BindLocalStorage(
95 const mojo::String& origin,
96 mojo::InterfaceRequest<LevelDBWrapper> request);
97
79 // Used for mojo-based LocalStorage implementation (behind 98 // Used for mojo-based LocalStorage implementation (behind
80 // --mojo-local-storage for now). Maps between an origin and its prefixed 99 // --mojo-local-storage for now). Maps between an origin and its prefixed
81 // LevelDB view. 100 // LevelDB view.
82 std::map<std::string, scoped_ptr<LevelDBWrapperImpl>> level_db_wrappers_; 101 std::map<std::string, scoped_ptr<LevelDBWrapperImpl>> level_db_wrappers_;
83 102
103 uint32_t mojo_user_id_;
michaeln 2016/03/05 01:38:54 I'd prefer to factor the new mojo based impl out i
Elliot Glaysher 2016/03/10 21:00:35 Moved all implementation details into their own in
84 scoped_refptr<DOMStorageContextImpl> context_; 104 scoped_refptr<DOMStorageContextImpl> context_;
85 105
106 enum ConnectionState {
107 NO_CONNECTION,
108 CONNECITON_IN_PROGRESS,
109 CONNECTED
110 } connection_state_;
111
112 scoped_ptr<MojoAppConnection> profile_connection_;
113 profile::ProfileServicePtr profile_service_;
114 filesystem::DirectoryPtr directory_;
115
116 scoped_ptr<MojoAppConnection> leveldb_connection_;
117 leveldb::LevelDBServicePtr leveldb_;
118 leveldb::LevelDBDatabasePtr database_;
michaeln 2016/03/05 01:38:54 Since we only need leveldb_connection_ and databas
Elliot Glaysher 2016/03/10 21:00:35 I previously tried to do this, and had problems. T
119
120 std::vector<base::Closure> on_database_opened_callbacks_;
121
122 base::WeakPtrFactory<DOMStorageContextWrapper> weak_ptr_factory_;
123
86 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper); 124 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper);
87 }; 125 };
88 126
89 } // namespace content 127 } // namespace content
90 128
91 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ 129 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698