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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "content/browser/indexed_db/indexed_db_quota_client.h" | 14 #include "content/browser/indexed_db/indexed_db_quota_client.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/indexed_db_info.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" |
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
22 #include "webkit/base/file_path_string_conversions.h" | 23 #include "webkit/base/file_path_string_conversions.h" |
23 #include "webkit/database/database_util.h" | 24 #include "webkit/database/database_util.h" |
24 #include "webkit/quota/quota_manager.h" | 25 #include "webkit/quota/quota_manager.h" |
25 #include "webkit/quota/special_storage_policy.h" | 26 #include "webkit/quota/special_storage_policy.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
116 std::vector<GURL> origins; | 117 std::vector<GURL> origins; |
117 std::set<GURL>* origins_set = GetOriginSet(); | 118 std::set<GURL>* origins_set = GetOriginSet(); |
118 for (std::set<GURL>::const_iterator iter = origins_set->begin(); | 119 for (std::set<GURL>::const_iterator iter = origins_set->begin(); |
119 iter != origins_set->end(); ++iter) { | 120 iter != origins_set->end(); ++iter) { |
120 origins.push_back(*iter); | 121 origins.push_back(*iter); |
121 } | 122 } |
122 return origins; | 123 return origins; |
123 } | 124 } |
124 | 125 |
| 126 std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() { |
| 127 std::vector<GURL> origins = GetAllOrigins(); |
| 128 std::vector<IndexedDBInfo> result; |
| 129 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
| 130 iter != origins.end(); ++iter) { |
| 131 const GURL& origin = *iter; |
| 132 |
| 133 result.push_back(IndexedDBInfo(origin, |
| 134 GetOriginDiskUsage(origin), |
| 135 GetOriginLastModified(origin))); |
| 136 } |
| 137 return result; |
| 138 } |
| 139 |
125 int64 IndexedDBContextImpl::GetOriginDiskUsage(const GURL& origin_url) { | 140 int64 IndexedDBContextImpl::GetOriginDiskUsage(const GURL& origin_url) { |
126 if (data_path_.empty() || !IsInOriginSet(origin_url)) | 141 if (data_path_.empty() || !IsInOriginSet(origin_url)) |
127 return 0; | 142 return 0; |
128 EnsureDiskUsageCacheInitialized(origin_url); | 143 EnsureDiskUsageCacheInitialized(origin_url); |
129 return origin_size_map_[origin_url]; | 144 return origin_size_map_[origin_url]; |
130 } | 145 } |
131 | 146 |
132 base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) { | 147 base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) { |
133 if (data_path_.empty() || !IsInOriginSet(origin_url)) | 148 if (data_path_.empty() || !IsInOriginSet(origin_url)) |
134 return base::Time(); | 149 return base::Time(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 return origin_set_.get(); | 379 return origin_set_.get(); |
365 } | 380 } |
366 | 381 |
367 void IndexedDBContextImpl::ResetCaches() { | 382 void IndexedDBContextImpl::ResetCaches() { |
368 origin_set_.reset(); | 383 origin_set_.reset(); |
369 origin_size_map_.clear(); | 384 origin_size_map_.clear(); |
370 space_available_map_.clear(); | 385 space_available_map_.clear(); |
371 } | 386 } |
372 | 387 |
373 } // namespace content | 388 } // namespace content |
OLD | NEW |