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

Side by Side Diff: webkit/dom_storage/dom_storage_cached_area.h

Issue 10383123: Switch to using the async DomStorage IPC messages and add a caching layer … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/nullable_string16.h"
14 #include "googleurl/src/gurl.h"
15
16 namespace dom_storage {
17
18 class DomStorageMap;
19 class DomStorageProxy;
20
21 class DomStorageCachedArea : public base::RefCounted<DomStorageCachedArea> {
22 public:
23 DomStorageCachedArea(int64 namespace_id, const GURL& origin,
24 DomStorageProxy* proxy);
25
26 int64 namespace_id() const { return namespace_id_; }
27 const GURL& origin() const { return origin_; }
28
29 unsigned GetLength(int connection_id);
30 NullableString16 GetKey(int connection_id, unsigned index);
31 NullableString16 GetItem(int connection_id, const string16& key);
32 bool SetItem(int connection_id, const string16& key, const string16& value,
33 const GURL& page_url);
34 void RemoveItem(int connection_id, const string16& key,
35 const GURL& page_url);
36 void Clear(int connection_id, const GURL& page_url);
37
38 void ApplyMutation(const NullableString16& key,
39 const NullableString16& old_value,
40 const NullableString16& new_value);
41
42 private:
43 friend class base::RefCounted<DomStorageCachedArea>;
44 ~DomStorageCachedArea();
45
46 // Primes the cache, loading all values for the area.
47 void Prime(int connection_id);
48 void PrimeIfNeeded(int connection_id) {
49 if (!map_)
50 Prime(connection_id);
51 }
52
53 // Async completion callbacks for proxied operations.
54 // These are used to maintain cache consistency by preventing
55 // mutation events from other processes from overwriting local
56 // changes made after the mutation.
57 void OnLoadComplete(bool success);
58 void OnSetItemComplete(const string16& key, bool success);
59 void OnClearComplete(bool success);
60 void OnRemoveItemComplete(const string16& key, bool success);
61
62 // Resets the class back to its newly constructed state.
63 void Reset();
64
65 int64 namespace_id_;
66 GURL origin_;
67 scoped_refptr<DomStorageMap> map_;
68 scoped_refptr<DomStorageProxy> proxy_;
69 base::WeakPtrFactory<DomStorageCachedArea> weak_factory_;
70
71 // Once a change to the local cache is made, incoming mutation
72 // events for the keys affected are ignored until we receive the
73 // completion callback corresponding to those local changes.
74 bool ignore_all_mutations_;
75 std::map<string16, int> ignore_key_mutations_;
76 };
77
78 } // namespace dom_storage
79
80 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698