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

Side by Side Diff: content/browser/indexed_db/indexed_db_context_impl.h

Issue 17518004: Move IndexedDB from WEBKIT_DEPRECATED to dedicated thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing files Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 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 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_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "content/browser/indexed_db/webidbfactory_impl.h" 16 #include "content/browser/indexed_db/webidbfactory_impl.h"
17 #include "content/public/browser/indexed_db_context.h" 17 #include "content/public/browser/indexed_db_context.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "webkit/common/quota/quota_types.h" 19 #include "webkit/common/quota/quota_types.h"
20 20
21 class GURL; 21 class GURL;
22 22
23 namespace base { 23 namespace base {
24 class FilePath; 24 class FilePath;
25 class MessageLoop;
25 class MessageLoopProxy; 26 class MessageLoopProxy;
26 } 27 }
27 28
28 namespace quota { 29 namespace quota {
29 class QuotaManagerProxy; 30 class QuotaManagerProxy;
30 class SpecialStoragePolicy; 31 class SpecialStoragePolicy;
31 } 32 }
32 33
33 namespace content { 34 namespace content {
34 35
35 class WebIDBDatabaseImpl; 36 class WebIDBDatabaseImpl;
36 37
37 class CONTENT_EXPORT IndexedDBContextImpl 38 class CONTENT_EXPORT IndexedDBContextImpl
38 : NON_EXPORTED_BASE(public IndexedDBContext) { 39 : NON_EXPORTED_BASE(public IndexedDBContext) {
39 public: 40 public:
40 // If |data_path| is empty, nothing will be saved to disk. 41 // If |data_path| is empty, nothing will be saved to disk.
41 IndexedDBContextImpl(const base::FilePath& data_path, 42 IndexedDBContextImpl(const base::FilePath& data_path,
42 quota::SpecialStoragePolicy* special_storage_policy, 43 quota::SpecialStoragePolicy* special_storage_policy,
43 quota::QuotaManagerProxy* quota_manager_proxy, 44 quota::QuotaManagerProxy* quota_manager_proxy,
44 base::MessageLoopProxy* webkit_thread_loop); 45 base::MessageLoop* message_loop);
jam 2013/06/21 16:00:50 question: why did you switch from MLP to ML? the f
jsbell 2013/06/21 16:34:16 Purely for the base::MessageLoop::current() == mes
jsbell 2013/06/21 16:49:47 Oh, RunsTasksOnCurrentThread should do it for the
jsbell 2013/06/21 17:38:21 And the TestThreadHelper can replaced by ThreadSim
45 46
46 WebIDBFactoryImpl* GetIDBFactory(); 47 WebIDBFactoryImpl* GetIDBFactory();
47 48
48 // The indexed db directory. 49 // The indexed db directory.
49 static const base::FilePath::CharType kIndexedDBDirectory[]; 50 static const base::FilePath::CharType kIndexedDBDirectory[];
50 51
51 // Disables the exit-time deletion of session-only data. 52 // Disables the exit-time deletion of session-only data.
52 void SetForceKeepSessionState() { force_keep_session_state_ = true; } 53 void SetForceKeepSessionState() { force_keep_session_state_ = true; }
53 54
54 // IndexedDBContext implementation: 55 // IndexedDBContext implementation:
56 virtual base::TaskRunner* TaskRunner() OVERRIDE;
57 virtual bool OnIndexedDBThread() const OVERRIDE;
55 virtual std::vector<GURL> GetAllOrigins() OVERRIDE; 58 virtual std::vector<GURL> GetAllOrigins() OVERRIDE;
56 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE; 59 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() OVERRIDE;
57 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE; 60 virtual int64 GetOriginDiskUsage(const GURL& origin_url) OVERRIDE;
58 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE; 61 virtual base::Time GetOriginLastModified(const GURL& origin_url) OVERRIDE;
59 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE; 62 virtual void DeleteForOrigin(const GURL& origin_url) OVERRIDE;
60 virtual base::FilePath GetFilePathForTesting( 63 virtual base::FilePath GetFilePathForTesting(
61 const std::string& origin_id) const OVERRIDE; 64 const std::string& origin_id) const OVERRIDE;
65 virtual void SetMessageLoopForTesting(
66 base::MessageLoop* message_loop) OVERRIDE;
62 67
63 // Methods called by IndexedDBDispatcherHost for quota support. 68 // Methods called by IndexedDBDispatcherHost for quota support.
64 void ConnectionOpened(const GURL& origin_url, WebIDBDatabaseImpl* db); 69 void ConnectionOpened(const GURL& origin_url, WebIDBDatabaseImpl* db);
65 void ConnectionClosed(const GURL& origin_url, WebIDBDatabaseImpl* db); 70 void ConnectionClosed(const GURL& origin_url, WebIDBDatabaseImpl* db);
66 void TransactionComplete(const GURL& origin_url); 71 void TransactionComplete(const GURL& origin_url);
67 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes); 72 bool WouldBeOverQuota(const GURL& origin_url, int64 additional_bytes);
68 bool IsOverQuota(const GURL& origin_url); 73 bool IsOverQuota(const GURL& origin_url);
69 74
70 quota::QuotaManagerProxy* quota_manager_proxy(); 75 quota::QuotaManagerProxy* quota_manager_proxy();
71 76
72 void ForceClose(const GURL& origin_url); 77 void ForceClose(const GURL& origin_url);
73 base::FilePath GetFilePath(const GURL& origin_url); 78 base::FilePath GetFilePath(const GURL& origin_url);
74 base::FilePath data_path() const { return data_path_; } 79 base::FilePath data_path() const { return data_path_; }
75 bool IsInOriginSet(const GURL& origin_url) { 80 bool IsInOriginSet(const GURL& origin_url) {
76 std::set<GURL>* set = GetOriginSet(); 81 std::set<GURL>* set = GetOriginSet();
77 return set->find(origin_url) != set->end(); 82 return set->find(origin_url) != set->end();
78 } 83 }
79 84
85 scoped_refptr<base::MessageLoopProxy> MessageLoopProxy();
jam 2013/06/21 16:00:50 nit: document
jsbell 2013/06/21 16:34:16 Done.
86
80 // For unit tests allow to override the |data_path_|. 87 // For unit tests allow to override the |data_path_|.
81 void set_data_path_for_testing(const base::FilePath& data_path) { 88 void set_data_path_for_testing(const base::FilePath& data_path) {
82 data_path_ = data_path; 89 data_path_ = data_path;
83 } 90 }
84 91
85 protected: 92 protected:
86 virtual ~IndexedDBContextImpl(); 93 virtual ~IndexedDBContextImpl();
87 94
88 private: 95 private:
89 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState); 96 FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState);
(...skipping 16 matching lines...) Expand all
106 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota); 113 void GotUpdatedQuota(const GURL& origin_url, int64 usage, int64 quota);
107 void QueryAvailableQuota(const GURL& origin_url); 114 void QueryAvailableQuota(const GURL& origin_url);
108 115
109 std::set<GURL>* GetOriginSet(); 116 std::set<GURL>* GetOriginSet();
110 bool AddToOriginSet(const GURL& origin_url) { 117 bool AddToOriginSet(const GURL& origin_url) {
111 return GetOriginSet()->insert(origin_url).second; 118 return GetOriginSet()->insert(origin_url).second;
112 } 119 }
113 void RemoveFromOriginSet(const GURL& origin_url) { 120 void RemoveFromOriginSet(const GURL& origin_url) {
114 GetOriginSet()->erase(origin_url); 121 GetOriginSet()->erase(origin_url);
115 } 122 }
123
116 // Only for testing. 124 // Only for testing.
117 void ResetCaches(); 125 void ResetCaches();
118 126
119 scoped_ptr<WebIDBFactoryImpl> idb_factory_; 127 scoped_ptr<WebIDBFactoryImpl> idb_factory_;
120 base::FilePath data_path_; 128 base::FilePath data_path_;
121 // If true, nothing (not even session-only data) should be deleted on exit. 129 // If true, nothing (not even session-only data) should be deleted on exit.
122 bool force_keep_session_state_; 130 bool force_keep_session_state_;
123 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 131 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
124 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; 132 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
133 base::MessageLoop* message_loop_;
125 scoped_ptr<std::set<GURL> > origin_set_; 134 scoped_ptr<std::set<GURL> > origin_set_;
126 OriginToSizeMap origin_size_map_; 135 OriginToSizeMap origin_size_map_;
127 OriginToSizeMap space_available_map_; 136 OriginToSizeMap space_available_map_;
128 typedef std::set<WebIDBDatabaseImpl*> ConnectionSet; 137 typedef std::set<WebIDBDatabaseImpl*> ConnectionSet;
129 std::map<GURL, ConnectionSet> connections_; 138 std::map<GURL, ConnectionSet> connections_;
130 139
131 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl); 140 DISALLOW_COPY_AND_ASSIGN(IndexedDBContextImpl);
132 }; 141 };
133 142
134 } // namespace content 143 } // namespace content
135 144
136 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_ 145 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698