| 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_context_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/trace_event/trace_event.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "content/browser/browser_main_loop.h" | 23 #include "content/browser/browser_main_loop.h" |
| 23 #include "content/browser/indexed_db/indexed_db_connection.h" | 24 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 24 #include "content/browser/indexed_db/indexed_db_database.h" | 25 #include "content/browser/indexed_db/indexed_db_database.h" |
| 25 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 26 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 26 #include "content/browser/indexed_db/indexed_db_factory_impl.h" | 27 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
| 27 #include "content/browser/indexed_db/indexed_db_quota_client.h" | 28 #include "content/browser/indexed_db/indexed_db_quota_client.h" |
| 28 #include "content/browser/indexed_db/indexed_db_tracing.h" | 29 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 29 #include "content/browser/indexed_db/indexed_db_transaction.h" | 30 #include "content/browser/indexed_db/indexed_db_transaction.h" |
| 30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 BrowserThread::IO, | 591 BrowserThread::IO, |
| 591 FROM_HERE, | 592 FROM_HERE, |
| 592 base::Bind( | 593 base::Bind( |
| 593 &IndexedDBContextImpl::QueryAvailableQuota, this, origin_url)); | 594 &IndexedDBContextImpl::QueryAvailableQuota, this, origin_url)); |
| 594 } | 595 } |
| 595 return; | 596 return; |
| 596 } | 597 } |
| 597 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 598 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 598 if (!quota_manager_proxy() || !quota_manager_proxy()->quota_manager()) | 599 if (!quota_manager_proxy() || !quota_manager_proxy()->quota_manager()) |
| 599 return; | 600 return; |
| 601 |
| 602 // crbug.com/349708 |
| 603 TRACE_EVENT0("io", "IndexedDBContextImpl::QueryAvailableQuota"); |
| 604 |
| 600 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( | 605 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( |
| 601 origin_url, | 606 origin_url, |
| 602 storage::kStorageTypeTemporary, | 607 storage::kStorageTypeTemporary, |
| 603 base::Bind(&IndexedDBContextImpl::GotUsageAndQuota, this, origin_url)); | 608 base::Bind(&IndexedDBContextImpl::GotUsageAndQuota, this, origin_url)); |
| 604 } | 609 } |
| 605 | 610 |
| 606 std::set<GURL>* IndexedDBContextImpl::GetOriginSet() { | 611 std::set<GURL>* IndexedDBContextImpl::GetOriginSet() { |
| 607 if (!origin_set_) { | 612 if (!origin_set_) { |
| 608 std::vector<GURL> origins; | 613 std::vector<GURL> origins; |
| 609 GetAllOriginsAndPaths(data_path_, &origins, NULL); | 614 GetAllOriginsAndPaths(data_path_, &origins, NULL); |
| 610 origin_set_.reset(new std::set<GURL>(origins.begin(), origins.end())); | 615 origin_set_.reset(new std::set<GURL>(origins.begin(), origins.end())); |
| 611 } | 616 } |
| 612 return origin_set_.get(); | 617 return origin_set_.get(); |
| 613 } | 618 } |
| 614 | 619 |
| 615 void IndexedDBContextImpl::ResetCaches() { | 620 void IndexedDBContextImpl::ResetCaches() { |
| 616 origin_set_.reset(); | 621 origin_set_.reset(); |
| 617 origin_size_map_.clear(); | 622 origin_size_map_.clear(); |
| 618 space_available_map_.clear(); | 623 space_available_map_.clear(); |
| 619 } | 624 } |
| 620 | 625 |
| 621 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { | 626 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { |
| 622 return task_runner_.get(); | 627 return task_runner_.get(); |
| 623 } | 628 } |
| 624 | 629 |
| 625 } // namespace content | 630 } // namespace content |
| OLD | NEW |