| OLD | NEW |
| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class LevelDBWrapperImpl; | 28 class LevelDBWrapperImpl; |
| 29 | 29 |
| 30 // This is owned by Storage Partition and encapsulates all its dom storage | 30 // This is owned by Storage Partition and encapsulates all its dom storage |
| 31 // state. | 31 // state. |
| 32 class CONTENT_EXPORT DOMStorageContextWrapper : | 32 class CONTENT_EXPORT DOMStorageContextWrapper : |
| 33 NON_EXPORTED_BASE(public DOMStorageContext), | 33 NON_EXPORTED_BASE(public DOMStorageContext), |
| 34 public base::RefCountedThreadSafe<DOMStorageContextWrapper> { | 34 public base::RefCountedThreadSafe<DOMStorageContextWrapper> { |
| 35 public: | 35 public: |
| 36 // If |data_path| is empty, nothing will be saved to disk. | 36 // If |data_path| is empty, nothing will be saved to disk. |
| 37 DOMStorageContextWrapper( | 37 DOMStorageContextWrapper( |
| 38 const std::string& mojo_user_id, |
| 38 const base::FilePath& data_path, | 39 const base::FilePath& data_path, |
| 40 const base::FilePath& local_partition_path, |
| 39 storage::SpecialStoragePolicy* special_storage_policy); | 41 storage::SpecialStoragePolicy* special_storage_policy); |
| 40 | 42 |
| 41 // DOMStorageContext implementation. | 43 // DOMStorageContext implementation. |
| 42 void GetLocalStorageUsage( | 44 void GetLocalStorageUsage( |
| 43 const GetLocalStorageUsageCallback& callback) override; | 45 const GetLocalStorageUsageCallback& callback) override; |
| 44 void GetSessionStorageUsage( | 46 void GetSessionStorageUsage( |
| 45 const GetSessionStorageUsageCallback& callback) override; | 47 const GetSessionStorageUsageCallback& callback) override; |
| 46 void DeleteLocalStorage(const GURL& origin) override; | 48 void DeleteLocalStorage(const GURL& origin) override; |
| 47 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override; | 49 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override; |
| 48 void SetSaveSessionStorageOnDisk() override; | 50 void SetSaveSessionStorageOnDisk() override; |
| 49 scoped_refptr<SessionStorageNamespace> RecreateSessionStorage( | 51 scoped_refptr<SessionStorageNamespace> RecreateSessionStorage( |
| 50 const std::string& persistent_id) override; | 52 const std::string& persistent_id) override; |
| 51 void StartScavengingUnusedSessionStorage() override; | 53 void StartScavengingUnusedSessionStorage() override; |
| 52 | 54 |
| 53 // Used by content settings to alter the behavior around | 55 // Used by content settings to alter the behavior around |
| 54 // what data to keep and what data to discard at shutdown. | 56 // what data to keep and what data to discard at shutdown. |
| 55 // The policy is not so straight forward to describe, see | 57 // The policy is not so straight forward to describe, see |
| 56 // the implementation for details. | 58 // the implementation for details. |
| 57 void SetForceKeepSessionState(); | 59 void SetForceKeepSessionState(); |
| 58 | 60 |
| 59 // Called when the BrowserContext/Profile is going away. | 61 // Called when the BrowserContext/Profile is going away. |
| 60 void Shutdown(); | 62 void Shutdown(); |
| 61 | 63 |
| 62 void Flush(); | 64 void Flush(); |
| 63 | 65 |
| 64 // See StoragePartitionService interface. | 66 // See StoragePartitionService interface. |
| 65 void OpenLocalStorage( | 67 void OpenLocalStorage(const mojo::String& origin, |
| 66 const mojo::String& origin, | 68 LevelDBWrapperRequest request); |
| 67 mojo::InterfaceRequest<LevelDBWrapper> request); | |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 friend class DOMStorageMessageFilter; // for access to context() | 71 friend class DOMStorageMessageFilter; // for access to context() |
| 71 friend class SessionStorageNamespaceImpl; // ditto | 72 friend class SessionStorageNamespaceImpl; // ditto |
| 72 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>; | 73 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>; |
| 73 | 74 |
| 74 ~DOMStorageContextWrapper() override; | 75 ~DOMStorageContextWrapper() override; |
| 75 DOMStorageContextImpl* context() const { return context_.get(); } | 76 DOMStorageContextImpl* context() const { return context_.get(); } |
| 76 | 77 |
| 77 void LevelDBWrapperImplHasNoBindings(const std::string& origin); | 78 // An inner class to keep all mojo-ish details together and not bleed them |
| 78 | 79 // through the public interface. |
| 79 // Used for mojo-based LocalStorage implementation (behind | 80 class MojoState; |
| 80 // --mojo-local-storage for now). Maps between an origin and its prefixed | 81 scoped_ptr<MojoState> mojo_state_; |
| 81 // LevelDB view. | |
| 82 std::map<std::string, scoped_ptr<LevelDBWrapperImpl>> level_db_wrappers_; | |
| 83 | 82 |
| 84 scoped_refptr<DOMStorageContextImpl> context_; | 83 scoped_refptr<DOMStorageContextImpl> context_; |
| 85 | 84 |
| 86 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper); | 85 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace content | 88 } // namespace content |
| 90 | 89 |
| 91 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ | 90 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_ |
| OLD | NEW |