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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 void GetAllOriginsOnWebKitThread( | 36 void GetAllOriginsOnWebKitThread( |
37 IndexedDBContextImpl* context, | 37 IndexedDBContextImpl* context, |
38 std::set<GURL>* origins_to_return) { | 38 std::set<GURL>* origins_to_return) { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
40 std::vector<GURL> all_origins = context->GetAllOrigins(); | 40 std::vector<GURL> all_origins = context->GetAllOrigins(); |
41 origins_to_return->insert(all_origins.begin(), all_origins.end()); | 41 origins_to_return->insert(all_origins.begin(), all_origins.end()); |
42 } | 42 } |
43 | 43 |
44 void DidGetOrigins( | 44 void DidGetOrigins( |
45 const IndexedDBQuotaClient::GetOriginsCallback& callback, | 45 const IndexedDBQuotaClient::GetOriginsCallback& callback, |
46 const std::set<GURL>* origins, | 46 const std::set<GURL>* origins) { |
47 quota::StorageType storage_type) { | |
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
49 callback.Run(*origins, storage_type); | 48 callback.Run(*origins); |
50 } | 49 } |
51 | 50 |
52 void GetOriginsForHostOnWebKitThread( | 51 void GetOriginsForHostOnWebKitThread( |
53 IndexedDBContextImpl* context, | 52 IndexedDBContextImpl* context, |
54 const std::string& host, | 53 const std::string& host, |
55 std::set<GURL>* origins_to_return) { | 54 std::set<GURL>* origins_to_return) { |
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
57 std::vector<GURL> all_origins = context->GetAllOrigins(); | 56 std::vector<GURL> all_origins = context->GetAllOrigins(); |
58 for (std::vector<GURL>::const_iterator iter = all_origins.begin(); | 57 for (std::vector<GURL>::const_iterator iter = all_origins.begin(); |
59 iter != all_origins.end(); ++iter) { | 58 iter != all_origins.end(); ++iter) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 106 } |
108 | 107 |
109 void IndexedDBQuotaClient::GetOriginsForType( | 108 void IndexedDBQuotaClient::GetOriginsForType( |
110 quota::StorageType type, | 109 quota::StorageType type, |
111 const GetOriginsCallback& callback) { | 110 const GetOriginsCallback& callback) { |
112 DCHECK(!callback.is_null()); | 111 DCHECK(!callback.is_null()); |
113 DCHECK(indexed_db_context_.get()); | 112 DCHECK(indexed_db_context_.get()); |
114 | 113 |
115 // All databases are in the temp namespace for now. | 114 // All databases are in the temp namespace for now. |
116 if (type != quota::kStorageTypeTemporary) { | 115 if (type != quota::kStorageTypeTemporary) { |
117 callback.Run(std::set<GURL>(), type); | 116 callback.Run(std::set<GURL>()); |
118 return; | 117 return; |
119 } | 118 } |
120 | 119 |
121 std::set<GURL>* origins_to_return = new std::set<GURL>(); | 120 std::set<GURL>* origins_to_return = new std::set<GURL>(); |
122 webkit_thread_message_loop_->PostTaskAndReply( | 121 webkit_thread_message_loop_->PostTaskAndReply( |
123 FROM_HERE, | 122 FROM_HERE, |
124 base::Bind(&GetAllOriginsOnWebKitThread, | 123 base::Bind(&GetAllOriginsOnWebKitThread, |
125 indexed_db_context_, | 124 indexed_db_context_, |
126 base::Unretained(origins_to_return)), | 125 base::Unretained(origins_to_return)), |
127 base::Bind(&DidGetOrigins, | 126 base::Bind(&DidGetOrigins, |
128 callback, | 127 callback, |
129 base::Owned(origins_to_return), | 128 base::Owned(origins_to_return))); |
130 type)); | |
131 } | 129 } |
132 | 130 |
133 void IndexedDBQuotaClient::GetOriginsForHost( | 131 void IndexedDBQuotaClient::GetOriginsForHost( |
134 quota::StorageType type, | 132 quota::StorageType type, |
135 const std::string& host, | 133 const std::string& host, |
136 const GetOriginsCallback& callback) { | 134 const GetOriginsCallback& callback) { |
137 DCHECK(!callback.is_null()); | 135 DCHECK(!callback.is_null()); |
138 DCHECK(indexed_db_context_.get()); | 136 DCHECK(indexed_db_context_.get()); |
139 | 137 |
140 // All databases are in the temp namespace for now. | 138 // All databases are in the temp namespace for now. |
141 if (type != quota::kStorageTypeTemporary) { | 139 if (type != quota::kStorageTypeTemporary) { |
142 callback.Run(std::set<GURL>(), type); | 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 webkit_thread_message_loop_->PostTaskAndReply( | 145 webkit_thread_message_loop_->PostTaskAndReply( |
148 FROM_HERE, | 146 FROM_HERE, |
149 base::Bind(&GetOriginsForHostOnWebKitThread, | 147 base::Bind(&GetOriginsForHostOnWebKitThread, |
150 indexed_db_context_, | 148 indexed_db_context_, |
151 host, | 149 host, |
152 base::Unretained(origins_to_return)), | 150 base::Unretained(origins_to_return)), |
153 base::Bind(&DidGetOrigins, | 151 base::Bind(&DidGetOrigins, |
154 callback, | 152 callback, |
155 base::Owned(origins_to_return), | 153 base::Owned(origins_to_return))); |
156 type)); | |
157 } | 154 } |
158 | 155 |
159 void IndexedDBQuotaClient::DeleteOriginData( | 156 void IndexedDBQuotaClient::DeleteOriginData( |
160 const GURL& origin, | 157 const GURL& origin, |
161 quota::StorageType type, | 158 quota::StorageType type, |
162 const DeletionCallback& callback) { | 159 const DeletionCallback& callback) { |
163 if (type != quota::kStorageTypeTemporary) { | 160 if (type != quota::kStorageTypeTemporary) { |
164 callback.Run(quota::kQuotaErrorNotSupported); | 161 callback.Run(quota::kQuotaErrorNotSupported); |
165 return; | 162 return; |
166 } | 163 } |
167 | 164 |
168 base::PostTaskAndReplyWithResult( | 165 base::PostTaskAndReplyWithResult( |
169 webkit_thread_message_loop_, | 166 webkit_thread_message_loop_, |
170 FROM_HERE, | 167 FROM_HERE, |
171 base::Bind(&DeleteOriginDataOnWebKitThread, | 168 base::Bind(&DeleteOriginDataOnWebKitThread, |
172 indexed_db_context_, | 169 indexed_db_context_, |
173 origin), | 170 origin), |
174 callback); | 171 callback); |
175 } | 172 } |
176 | 173 |
177 } // namespace content | 174 } // namespace content |
OLD | NEW |