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

Side by Side Diff: chrome/browser/in_process_webkit/dom_storage_context.h

Issue 258010: Reverting 27759. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
7 7
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
10 11
11 class StorageArea; 12 class StorageArea;
12 class StorageNamespace; 13 class StorageNamespace;
13 class WebKitContext; 14 class WebKitContext;
14 15
15 // This is owned by WebKitContext and is all the dom storage information that's 16 // This is owned by WebKitContext and is all the dom storage information that's
16 // shared by all the ResourceMessageFilter/DOMStorageDispatcherHosts that share 17 // shared by all the ResourceMessageFilter/DOMStorageDispatcherHosts that share
17 // the same profile. The specifics of responsibilities are fairly well 18 // the same profile. The specifics of responsibilities are fairly well
18 // documented here and in StorageNamespace and StorageArea. 19 // documented here and in StorageNamespace and StorageArea. Everything is only
20 // to be accessed on the WebKit thread unless noted otherwise.
19 class DOMStorageContext { 21 class DOMStorageContext {
20 public: 22 public:
21 explicit DOMStorageContext(WebKitContext* webkit_context); 23 explicit DOMStorageContext(WebKitContext* webkit_context);
22 ~DOMStorageContext(); 24 ~DOMStorageContext();
23 25
24 // Get the local storage instance. The pointer is owned by this class. 26 // Get the local storage instance. The pointer is owned by this class.
25 StorageNamespace* LocalStorage(); 27 StorageNamespace* LocalStorage();
26 28
27 // Get a new session storage namespace (but it's still owned by this class). 29 // Get a new session storage namespace (but it's still owned by this class).
28 StorageNamespace* NewSessionStorage(); 30 StorageNamespace* NewSessionStorage();
29 31
30 // Allocate a new storage ___ id. 32 // Allocate a new storage ___ id.
31 int64 AllocateStorageAreaId() { return ++last_storage_area_id_; } 33 int64 AllocateStorageAreaId() { return ++last_storage_area_id_; }
32 int64 AllocateStorageNamespaceId() { return ++last_storage_namespace_id_; } 34 int64 AllocateStorageNamespaceId() { return ++last_storage_namespace_id_; }
33 35
34 // Various storage area methods. The storage area is owned by one of the 36 // Various storage area methods. The storage area is owned by one of the
35 // namespaces that's owned by this class. 37 // namespaces that's owned by this class.
36 void RegisterStorageArea(StorageArea* storage_area); 38 void RegisterStorageArea(StorageArea* storage_area);
37 void UnregisterStorageArea(StorageArea* storage_area); 39 void UnregisterStorageArea(StorageArea* storage_area);
38 StorageArea* GetStorageArea(int64 id); 40 StorageArea* GetStorageArea(int64 id);
39 41
40 // Get a namespace from an id. What's returned is owned by this class. The 42 // Get a namespace from an id. What's returned is owned by this class. The
41 // caller of GetStorageNamespace must immediately register itself with the 43 // caller of GetStorageNamespace must immediately register itself with the
42 // returned StorageNamespace. 44 // returned StorageNamespace.
43 void RegisterStorageNamespace(StorageNamespace* storage_namespace); 45 void RegisterStorageNamespace(StorageNamespace* storage_namespace);
44 void UnregisterStorageNamespace(StorageNamespace* storage_namespace); 46 void UnregisterStorageNamespace(StorageNamespace* storage_namespace);
45 StorageNamespace* GetStorageNamespace(int64 id); 47 StorageNamespace* GetStorageNamespace(int64 id);
46 48
49 // Sometimes an event from one DOM storage dispatcher host requires
50 // communication to all of them.
51 typedef base::hash_set<DOMStorageDispatcherHost*> DispatcherHostSet;
52 void RegisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host);
53 void UnregisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host);
54 const DispatcherHostSet* GetDispatcherHostSet() const;
55
47 // The special ID used for local storage. 56 // The special ID used for local storage.
48 static const int64 kLocalStorageNamespaceId = 0; 57 static const int64 kLocalStorageNamespaceId = 0;
49 58
50 private: 59 private:
51 // The last used storage_area_id and storage_namespace_id's. 60 // The last used storage_area_id and storage_namespace_id's.
52 static const int64 kFirstStorageAreaId = 1; 61 static const int64 kFirstStorageAreaId = 1;
53 int64 last_storage_area_id_; 62 int64 last_storage_area_id_;
54 static const int64 kFirstStorageNamespaceId = 1; 63 static const int64 kFirstStorageNamespaceId = 1;
55 int64 last_storage_namespace_id_; 64 int64 last_storage_namespace_id_;
56 65
57 // We're owned by this WebKit context. Used while instantiating LocalStorage. 66 // We're owned by this WebKit context. Used while instantiating LocalStorage.
58 WebKitContext* webkit_context_; 67 WebKitContext* webkit_context_;
59 68
69 // All the DOMStorageDispatcherHosts that are attached to us. ONLY USE ON THE
70 // IO THREAD!
71 DispatcherHostSet dispatcher_host_set_;
72
60 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace 73 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace
61 // (which does own them) will notify us when we should remove the entries. 74 // (which does own them) will notify us when we should remove the entries.
62 typedef base::hash_map<int64, StorageArea*> StorageAreaMap; 75 typedef base::hash_map<int64, StorageArea*> StorageAreaMap;
63 StorageAreaMap storage_area_map_; 76 StorageAreaMap storage_area_map_;
64 77
65 // Maps ids to StorageNamespaces. We own these objects. 78 // Maps ids to StorageNamespaces. We own these objects.
66 typedef base::hash_map<int64, StorageNamespace*> StorageNamespaceMap; 79 typedef base::hash_map<int64, StorageNamespace*> StorageNamespaceMap;
67 StorageNamespaceMap storage_namespace_map_; 80 StorageNamespaceMap storage_namespace_map_;
68 81
69 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); 82 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext);
70 }; 83 };
71 84
72 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 85 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/in_process_webkit/browser_webkitclient_impl.cc ('k') | chrome/browser/in_process_webkit/dom_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698