OLD | NEW |
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 #include "content/browser/indexed_db/indexed_db_quota_client.h" | 5 #include "content/browser/indexed_db/indexed_db_quota_client.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return; | 83 return; |
84 } | 84 } |
85 | 85 |
86 // No task runner means unit test; no cleanup necessary. | 86 // No task runner means unit test; no cleanup necessary. |
87 if (!indexed_db_context_->TaskRunner()) { | 87 if (!indexed_db_context_->TaskRunner()) { |
88 callback.Run(0); | 88 callback.Run(0); |
89 return; | 89 return; |
90 } | 90 } |
91 | 91 |
92 base::PostTaskAndReplyWithResult( | 92 base::PostTaskAndReplyWithResult( |
93 indexed_db_context_->TaskRunner(), | 93 indexed_db_context_->TaskRunner(), FROM_HERE, |
94 FROM_HERE, | 94 base::Bind(&GetOriginUsageOnIndexedDBThread, |
95 base::Bind( | 95 base::RetainedRef(indexed_db_context_), origin_url), |
96 &GetOriginUsageOnIndexedDBThread, indexed_db_context_, origin_url), | |
97 callback); | 96 callback); |
98 } | 97 } |
99 | 98 |
100 void IndexedDBQuotaClient::GetOriginsForType( | 99 void IndexedDBQuotaClient::GetOriginsForType( |
101 storage::StorageType type, | 100 storage::StorageType type, |
102 const GetOriginsCallback& callback) { | 101 const GetOriginsCallback& callback) { |
103 DCHECK(!callback.is_null()); | 102 DCHECK(!callback.is_null()); |
104 DCHECK(indexed_db_context_.get()); | 103 DCHECK(indexed_db_context_.get()); |
105 | 104 |
106 // All databases are in the temp namespace for now. | 105 // All databases are in the temp namespace for now. |
107 if (type != storage::kStorageTypeTemporary) { | 106 if (type != storage::kStorageTypeTemporary) { |
108 callback.Run(std::set<GURL>()); | 107 callback.Run(std::set<GURL>()); |
109 return; | 108 return; |
110 } | 109 } |
111 | 110 |
112 // No task runner means unit test; no cleanup necessary. | 111 // No task runner means unit test; no cleanup necessary. |
113 if (!indexed_db_context_->TaskRunner()) { | 112 if (!indexed_db_context_->TaskRunner()) { |
114 callback.Run(std::set<GURL>()); | 113 callback.Run(std::set<GURL>()); |
115 return; | 114 return; |
116 } | 115 } |
117 | 116 |
118 std::set<GURL>* origins_to_return = new std::set<GURL>(); | 117 std::set<GURL>* origins_to_return = new std::set<GURL>(); |
119 indexed_db_context_->TaskRunner()->PostTaskAndReply( | 118 indexed_db_context_->TaskRunner()->PostTaskAndReply( |
120 FROM_HERE, | 119 FROM_HERE, base::Bind(&GetAllOriginsOnIndexedDBThread, |
121 base::Bind(&GetAllOriginsOnIndexedDBThread, | 120 base::RetainedRef(indexed_db_context_), |
122 indexed_db_context_, | 121 base::Unretained(origins_to_return)), |
123 base::Unretained(origins_to_return)), | |
124 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); | 122 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); |
125 } | 123 } |
126 | 124 |
127 void IndexedDBQuotaClient::GetOriginsForHost( | 125 void IndexedDBQuotaClient::GetOriginsForHost( |
128 storage::StorageType type, | 126 storage::StorageType type, |
129 const std::string& host, | 127 const std::string& host, |
130 const GetOriginsCallback& callback) { | 128 const GetOriginsCallback& callback) { |
131 DCHECK(!callback.is_null()); | 129 DCHECK(!callback.is_null()); |
132 DCHECK(indexed_db_context_.get()); | 130 DCHECK(indexed_db_context_.get()); |
133 | 131 |
134 // All databases are in the temp namespace for now. | 132 // All databases are in the temp namespace for now. |
135 if (type != storage::kStorageTypeTemporary) { | 133 if (type != storage::kStorageTypeTemporary) { |
136 callback.Run(std::set<GURL>()); | 134 callback.Run(std::set<GURL>()); |
137 return; | 135 return; |
138 } | 136 } |
139 | 137 |
140 // No task runner means unit test; no cleanup necessary. | 138 // No task runner means unit test; no cleanup necessary. |
141 if (!indexed_db_context_->TaskRunner()) { | 139 if (!indexed_db_context_->TaskRunner()) { |
142 callback.Run(std::set<GURL>()); | 140 callback.Run(std::set<GURL>()); |
143 return; | 141 return; |
144 } | 142 } |
145 | 143 |
146 std::set<GURL>* origins_to_return = new std::set<GURL>(); | 144 std::set<GURL>* origins_to_return = new std::set<GURL>(); |
147 indexed_db_context_->TaskRunner()->PostTaskAndReply( | 145 indexed_db_context_->TaskRunner()->PostTaskAndReply( |
148 FROM_HERE, | 146 FROM_HERE, base::Bind(&GetOriginsForHostOnIndexedDBThread, |
149 base::Bind(&GetOriginsForHostOnIndexedDBThread, | 147 base::RetainedRef(indexed_db_context_), host, |
150 indexed_db_context_, | 148 base::Unretained(origins_to_return)), |
151 host, | |
152 base::Unretained(origins_to_return)), | |
153 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); | 149 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); |
154 } | 150 } |
155 | 151 |
156 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, | 152 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, |
157 storage::StorageType type, | 153 storage::StorageType type, |
158 const DeletionCallback& callback) { | 154 const DeletionCallback& callback) { |
159 if (type != storage::kStorageTypeTemporary) { | 155 if (type != storage::kStorageTypeTemporary) { |
160 callback.Run(storage::kQuotaErrorNotSupported); | 156 callback.Run(storage::kQuotaErrorNotSupported); |
161 return; | 157 return; |
162 } | 158 } |
163 | 159 |
164 // No task runner means unit test; no cleanup necessary. | 160 // No task runner means unit test; no cleanup necessary. |
165 if (!indexed_db_context_->TaskRunner()) { | 161 if (!indexed_db_context_->TaskRunner()) { |
166 callback.Run(storage::kQuotaStatusOk); | 162 callback.Run(storage::kQuotaStatusOk); |
167 return; | 163 return; |
168 } | 164 } |
169 | 165 |
170 base::PostTaskAndReplyWithResult( | 166 base::PostTaskAndReplyWithResult( |
171 indexed_db_context_->TaskRunner(), | 167 indexed_db_context_->TaskRunner(), FROM_HERE, |
172 FROM_HERE, | 168 base::Bind(&DeleteOriginDataOnIndexedDBThread, |
173 base::Bind( | 169 base::RetainedRef(indexed_db_context_), origin), |
174 &DeleteOriginDataOnIndexedDBThread, indexed_db_context_, origin), | |
175 callback); | 170 callback); |
176 } | 171 } |
177 | 172 |
178 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const { | 173 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const { |
179 return type == storage::kStorageTypeTemporary; | 174 return type == storage::kStorageTypeTemporary; |
180 } | 175 } |
181 | 176 |
182 } // namespace content | 177 } // namespace content |
OLD | NEW |