Index: chrome/browser/in_process_webkit/dom_storage_context.h |
=================================================================== |
--- chrome/browser/in_process_webkit/dom_storage_context.h (revision 36257) |
+++ chrome/browser/in_process_webkit/dom_storage_context.h (working copy) |
@@ -28,15 +28,15 @@ |
explicit DOMStorageContext(WebKitContext* webkit_context); |
virtual ~DOMStorageContext(); |
- // Get the local storage instance. The pointer is owned by this class. |
- DOMStorageNamespace* LocalStorage(); |
+ // Allocate a new storage area id. Only call on the WebKit thread. |
+ int64 AllocateStorageAreaId(); |
- // Get a new session storage namespace (but it's still owned by this class). |
- DOMStorageNamespace* NewSessionStorage(); |
+ // Allocate a new session storage id. Only call on the UI or IO thread. |
+ int64 AllocateSessionStorageNamespaceId(); |
- // Allocate a new storage ___ id. |
- int64 AllocateStorageAreaId() { return ++last_storage_area_id_; } |
- int64 AllocateStorageNamespaceId() { return ++last_storage_namespace_id_; } |
+ // Clones a session storage namespace and returns the cloned namespaces' id. |
+ // Only call on the IO thread. |
+ int64 CloneSessionStorage(int64 original_id); |
// Various storage area methods. The storage area is owned by one of the |
// namespaces that's owned by this class. |
@@ -44,13 +44,14 @@ |
void UnregisterStorageArea(DOMStorageArea* storage_area); |
DOMStorageArea* GetStorageArea(int64 id); |
- // Get a namespace from an id. What's returned is owned by this class. The |
- // caller of GetStorageNamespace must immediately register itself with the |
- // returned StorageNamespace. |
- void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); |
- void UnregisterStorageNamespace(DOMStorageNamespace* storage_namespace); |
- DOMStorageNamespace* GetStorageNamespace(int64 id); |
+ // Called on WebKit thread when a session storage namespace can be deleted. |
+ void DeleteSessionStorageNamespace(int64 namespace_id); |
+ // Get a namespace from an id. What's returned is owned by this class. If |
+ // allocation_allowed is true, then this function will create the storage |
+ // namespace if it hasn't been already. |
+ DOMStorageNamespace* GetStorageNamespace(int64 id, bool allocation_allowed); |
+ |
// Sometimes an event from one DOM storage dispatcher host requires |
// communication to all of them. |
typedef std::set<DOMStorageDispatcherHost*> DispatcherHostSet; |
@@ -65,15 +66,31 @@ |
// date that's supplied. |
void DeleteDataModifiedSince(const base::Time& cutoff); |
- // The special ID used for local storage. |
- static const int64 kLocalStorageNamespaceId = 0; |
+ private: |
+ // Get the local storage instance. The object is owned by this class. |
+ DOMStorageNamespace* CreateLocalStorage(); |
- private: |
- // The last used storage_area_id and storage_namespace_id's. |
- static const int64 kFirstStorageAreaId = 1; |
+ // Get a new session storage namespace. The object is owned by this class. |
+ DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); |
+ |
+ // Used internally to register storage namespaces we create. |
+ void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); |
+ |
+ // The WebKit thread half of CloneSessionStorage above. Static because we |
+ // DOMStorageContext isn't ref counted and so we can't use a runnable method. |
+ // That said, we know this is safe because this class is destroyed on the |
+ // WebKit thread, so there's no way it could be destroyed before this is run. |
+ static void CompleteCloningSessionStorage(DOMStorageContext* context, |
+ int64 existing_id, int64 clone_id); |
+ |
+ // The last used storage_area_id and storage_namespace_id's. For the storage |
+ // namespaces, IDs allocated on the UI thread are positive and count up while |
+ // IDs allocated on the IO thread are negative and count down. This allows us |
+ // to allocate unique IDs on both without any locking. All storage area ids |
+ // are allocated on the WebKit thread. |
int64 last_storage_area_id_; |
- static const int64 kFirstStorageNamespaceId = 1; |
- int64 last_storage_namespace_id_; |
+ int64 last_session_storage_namespace_id_on_ui_thread_; |
+ int64 last_session_storage_namespace_id_on_io_thread_; |
// We're owned by this WebKit context. Used while instantiating LocalStorage. |
WebKitContext* webkit_context_; |