Index: webkit/dom_storage/dom_storage_cached_area.h |
=================================================================== |
--- webkit/dom_storage/dom_storage_cached_area.h (revision 0) |
+++ webkit/dom_storage/dom_storage_cached_area.h (revision 0) |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
+#define WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
+#pragma once |
+ |
+#include <map> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/nullable_string16.h" |
+#include "googleurl/src/gurl.h" |
+ |
+namespace dom_storage { |
+ |
+class DomStorageMap; |
+class DomStorageProxy; |
+ |
+class DomStorageCachedArea : public base::RefCounted<DomStorageCachedArea> { |
+ public: |
+ DomStorageCachedArea(int64 namespace_id, const GURL& origin, |
+ DomStorageProxy* proxy); |
+ |
+ int64 namespace_id() const { return namespace_id_; } |
+ const GURL& origin() const { return origin_; } |
+ |
+ unsigned GetLength(int connection_id); |
+ NullableString16 GetKey(int connection_id, unsigned index); |
+ NullableString16 GetItem(int connection_id, const string16& key); |
+ bool SetItem(int connection_id, const string16& key, const string16& value, |
+ const GURL& page_url); |
+ void RemoveItem(int connection_id, const string16& key, |
+ const GURL& page_url); |
+ void Clear(int connection_id, const GURL& page_url); |
+ |
+ void ApplyMutation(const NullableString16& key, |
+ const NullableString16& old_value, |
+ const NullableString16& new_value); |
+ |
+ private: |
+ friend class base::RefCounted<DomStorageCachedArea>; |
+ ~DomStorageCachedArea(); |
+ |
+ // Primes the cache, loading all values for the area. |
+ void Prime(int connection_id); |
+ void PrimeIfNeeded(int connection_id) { |
+ if (!map_) |
+ Prime(connection_id); |
+ } |
+ |
+ // Async completion callbacks for proxied operations. |
+ // These are used to maintain cache consistency by preventing |
+ // mutation events from other processes from overwriting local |
+ // changes made after the mutation. |
+ void OnLoadComplete(bool success); |
+ void OnSetItemComplete(const string16& key, bool success); |
+ void OnClearComplete(bool success); |
+ void OnRemoveItemComplete(const string16& key, bool success); |
+ |
+ // Resets the class back to its newly constructed state. |
+ void Reset(); |
+ |
+ int64 namespace_id_; |
+ GURL origin_; |
+ scoped_refptr<DomStorageMap> map_; |
+ scoped_refptr<DomStorageProxy> proxy_; |
+ base::WeakPtrFactory<DomStorageCachedArea> weak_factory_; |
+ |
+ // Once a change to the local cache is made, incoming mutation |
+ // events for the keys affected are ignored until we receive the |
+ // completion callback corresponding to those local changes. |
+ bool ignore_all_mutations_; |
+ std::map<string16, int> ignore_key_mutations_; |
+}; |
+ |
+} // namespace dom_storage |
+ |
+#endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
Property changes on: webkit\dom_storage\dom_storage_cached_area.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |