| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 12 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
| 15 #include "storage/browser/database/database_util.h" | 15 #include "storage/browser/database/database_util.h" |
| 16 #include "url/origin.h" |
| 16 | 17 |
| 17 using storage::QuotaClient; | 18 using storage::QuotaClient; |
| 18 using storage::DatabaseUtil; | 19 using storage::DatabaseUtil; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 storage::QuotaStatusCode DeleteOriginDataOnIndexedDBThread( | 24 storage::QuotaStatusCode DeleteOriginDataOnIndexedDBThread( |
| 24 IndexedDBContextImpl* context, | 25 IndexedDBContextImpl* context, |
| 25 const GURL& origin) { | 26 const GURL& origin) { |
| 26 context->DeleteForOrigin(origin); | 27 context->DeleteForOrigin(origin); |
| 27 return storage::kQuotaStatusOk; | 28 return storage::kQuotaStatusOk; |
| 28 } | 29 } |
| 29 | 30 |
| 30 int64_t GetOriginUsageOnIndexedDBThread(IndexedDBContextImpl* context, | 31 int64_t GetOriginUsageOnIndexedDBThread(IndexedDBContextImpl* context, |
| 31 const GURL& origin) { | 32 const GURL& origin) { |
| 32 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); | 33 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); |
| 33 return context->GetOriginDiskUsage(origin); | 34 return context->GetOriginDiskUsage(origin); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void GetAllOriginsOnIndexedDBThread(IndexedDBContextImpl* context, | 37 void GetAllOriginsOnIndexedDBThread(IndexedDBContextImpl* context, |
| 37 std::set<GURL>* origins_to_return) { | 38 std::set<GURL>* origins_to_return) { |
| 38 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); | 39 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); |
| 39 for (const auto& origin : context->GetAllOrigins()) | 40 for (const auto& origin : context->GetAllOrigins()) |
| 40 origins_to_return->insert(GURL(origin.Serialize())); | 41 origins_to_return->insert(origin.GetURL()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void DidGetOrigins(const IndexedDBQuotaClient::GetOriginsCallback& callback, | 44 void DidGetOrigins(const IndexedDBQuotaClient::GetOriginsCallback& callback, |
| 44 const std::set<GURL>* origins) { | 45 const std::set<GURL>* origins) { |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 46 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 46 callback.Run(*origins); | 47 callback.Run(*origins); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void GetOriginsForHostOnIndexedDBThread(IndexedDBContextImpl* context, | 50 void GetOriginsForHostOnIndexedDBThread(IndexedDBContextImpl* context, |
| 50 const std::string& host, | 51 const std::string& host, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 base::Bind(&DeleteOriginDataOnIndexedDBThread, | 169 base::Bind(&DeleteOriginDataOnIndexedDBThread, |
| 169 base::RetainedRef(indexed_db_context_), origin), | 170 base::RetainedRef(indexed_db_context_), origin), |
| 170 callback); | 171 callback); |
| 171 } | 172 } |
| 172 | 173 |
| 173 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const { | 174 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const { |
| 174 return type == storage::kStorageTypeTemporary; | 175 return type == storage::kStorageTypeTemporary; |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace content | 178 } // namespace content |
| OLD | NEW |