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

Side by Side Diff: content/browser/in_process_webkit/dom_storage_context_impl.h

Issue 9704048: Make the content::DOMStorageContext methods callable on the main thread and hide the threading deta… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h"
15 #include "base/time.h" 16 #include "base/time.h"
16 #include "content/public/browser/dom_storage_context.h" 17 #include "content/public/browser/dom_storage_context.h"
17 18
18 class DOMStorageArea; 19 class DOMStorageArea;
19 class DOMStorageMessageFilter; 20 class DOMStorageMessageFilter;
20 class DOMStorageNamespace; 21 class DOMStorageNamespace;
21 22
22 namespace base { 23 namespace base {
23 class MessageLoopProxy; 24 class MessageLoopProxy;
24 class SequencedTaskRunner; 25 class SequencedTaskRunner;
25 } 26 }
26 27
27 namespace quota { 28 namespace quota {
28 class SpecialStoragePolicy; 29 class SpecialStoragePolicy;
29 } 30 }
30 31
31 // This is owned by BrowserContext and is all the dom storage information that's 32 // This is owned by BrowserContext and is all the dom storage information that's
32 // shared by all the DOMStorageMessageFilters that share the same browser 33 // shared by all the DOMStorageMessageFilters that share the same browser
33 // context. The specifics of responsibilities are fairly well documented here 34 // context. The specifics of responsibilities are fairly well documented here
34 // and in StorageNamespace and StorageArea. Everything is only to be accessed 35 // and in StorageNamespace and StorageArea. Everything is only to be accessed
35 // on the WebKit thread unless noted otherwise. 36 // on the WebKit thread unless noted otherwise.
36 class CONTENT_EXPORT DOMStorageContextImpl : 37 class CONTENT_EXPORT DOMStorageContextImpl :
37 NON_EXPORTED_BASE(public content::DOMStorageContext) { 38 NON_EXPORTED_BASE(public content::DOMStorageContext),
39 public base::RefCountedThreadSafe<DOMStorageContextImpl> {
38 public: 40 public:
39 // If |data_path| is empty, nothing will be saved to disk. 41 // If |data_path| is empty, nothing will be saved to disk.
40 DOMStorageContextImpl(const FilePath& data_path, 42 DOMStorageContextImpl(const FilePath& data_path,
41 quota::SpecialStoragePolicy* special_storage_policy); 43 quota::SpecialStoragePolicy* special_storage_policy);
42 virtual ~DOMStorageContextImpl(); 44 virtual ~DOMStorageContextImpl();
43 45
44 // DOMStorageContext implementation: 46 // DOMStorageContext implementation:
45 virtual base::SequencedTaskRunner* task_runner() const OVERRIDE; 47 virtual void GetAllStorageFiles(GetAllStorageFilesCallback callback) OVERRIDE;
46 virtual std::vector<FilePath> GetAllStorageFiles() OVERRIDE;
47 virtual FilePath GetFilePath(const string16& origin_id) const OVERRIDE; 48 virtual FilePath GetFilePath(const string16& origin_id) const OVERRIDE;
48 virtual void DeleteForOrigin(const string16& origin_id) OVERRIDE; 49 virtual void DeleteForOrigin(const string16& origin_id) OVERRIDE;
49 virtual void DeleteLocalStorageFile(const FilePath& file_path) OVERRIDE; 50 virtual void DeleteLocalStorageFile(const FilePath& file_path) OVERRIDE;
50 virtual void DeleteDataModifiedSince(const base::Time& cutoff) OVERRIDE; 51 virtual void DeleteDataModifiedSince(const base::Time& cutoff) OVERRIDE;
51 52
52 // Invalid storage id. No storage session will ever report this value. 53 // Invalid storage id. No storage session will ever report this value.
53 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with 54 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with
54 // interactions with non-existent storage sessions. 55 // interactions with non-existent storage sessions.
55 static const int64 kInvalidStorageId = -1; 56 static const int64 kInvalidStorageId = -1;
56 57
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 120
120 // Get a new session storage namespace. The object is owned by this class. 121 // Get a new session storage namespace. The object is owned by this class.
121 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); 122 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id);
122 123
123 // Used internally to register storage namespaces we create. 124 // Used internally to register storage namespaces we create.
124 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); 125 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace);
125 126
126 // The WebKit thread half of CloneSessionStorage above. 127 // The WebKit thread half of CloneSessionStorage above.
127 void CompleteCloningSessionStorage(int64 existing_id, int64 clone_id); 128 void CompleteCloningSessionStorage(int64 existing_id, int64 clone_id);
128 129
130 void RunAllStorageFilesCallback(
131 const std::vector<FilePath>& files, GetAllStorageFilesCallback callback);
132
129 // The last used storage_area_id and storage_namespace_id's. For the storage 133 // The last used storage_area_id and storage_namespace_id's. For the storage
130 // namespaces, IDs allocated on the UI thread are positive and count up while 134 // namespaces, IDs allocated on the UI thread are positive and count up while
131 // IDs allocated on the IO thread are negative and count down. This allows us 135 // IDs allocated on the IO thread are negative and count down. This allows us
132 // to allocate unique IDs on both without any locking. All storage area ids 136 // to allocate unique IDs on both without any locking. All storage area ids
133 // are allocated on the WebKit thread. 137 // are allocated on the WebKit thread.
134 int64 last_storage_area_id_; 138 int64 last_storage_area_id_;
135 int64 last_session_storage_namespace_id_on_ui_thread_; 139 int64 last_session_storage_namespace_id_on_ui_thread_;
136 int64 last_session_storage_namespace_id_on_io_thread_; 140 int64 last_session_storage_namespace_id_on_io_thread_;
137 141
138 // True if the destructor should delete its files. 142 // True if the destructor should delete its files.
(...skipping 22 matching lines...) Expand all
161 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; 165 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap;
162 StorageNamespaceMap storage_namespace_map_; 166 StorageNamespaceMap storage_namespace_map_;
163 167
164 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 168 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
165 scoped_refptr<base::MessageLoopProxy> webkit_message_loop_; 169 scoped_refptr<base::MessageLoopProxy> webkit_message_loop_;
166 170
167 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl); 171 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl);
168 }; 172 };
169 173
170 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_ 174 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698