Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1144)

Unified Diff: content/browser/indexed_db/indexed_db_internals_ui.cc

Issue 14156003: Support multiple storage partitions in chrome://indexeddb-internals/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_internals_ui.cc
diff --git a/content/browser/indexed_db/indexed_db_internals_ui.cc b/content/browser/indexed_db/indexed_db_internals_ui.cc
index 6d0871c36ff86839c44a6b390bf3335cea7a0989..6e93aaf7fe614adcbc4ccb5572b626a70b7382bf 100644
--- a/content/browser/indexed_db/indexed_db_internals_ui.cc
+++ b/content/browser/indexed_db/indexed_db_internals_ui.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/threading/platform_thread.h"
#include "base/values.h"
+#include "base/memory/scoped_vector.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
@@ -45,23 +46,35 @@ IndexedDBInternalsUI::IndexedDBInternalsUI(WebUI* web_ui)
IndexedDBInternalsUI::~IndexedDBInternalsUI() {
}
+void IndexedDBInternalsUI::AddContextFromStoragePartition(
+ ContextList* contexts,
+ std::vector<base::FilePath>* paths,
+ StoragePartition* partition) {
+ scoped_refptr<IndexedDBContext> context = partition->GetIndexedDBContext();
+ contexts->push_back(context);
+ paths->push_back(partition->GetPath());
+}
+
void IndexedDBInternalsUI::GetAllOrigins(const base::ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserContext* browser_context =
web_ui()->GetWebContents()->GetBrowserContext();
- // TODO(alecflett): do this for each storage partition in the context
- StoragePartition* partition =
- BrowserContext::GetDefaultStoragePartition(browser_context);
- scoped_refptr<IndexedDBContext> context = partition->GetIndexedDBContext();
+ scoped_ptr<std::vector<base::FilePath> >
+ paths(new std::vector<base::FilePath>);
+ scoped_ptr<ContextList> contexts(new ContextList);
+ BrowserContext::StoragePartitionCallback cb =
+ base::Bind(&AddContextFromStoragePartition, contexts.get(), paths.get());
+ BrowserContext::ForEachStoragePartition(browser_context, cb);
BrowserThread::PostTask(
BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
base::Bind(
&IndexedDBInternalsUI::GetAllOriginsOnWebkitThread,
base::Unretained(this),
- context));
+ base::Passed(&contexts),
+ base::Passed(&paths)));
}
bool HostNameComparator(const IndexedDBInfo& i, const IndexedDBInfo& j) {
@@ -69,21 +82,34 @@ bool HostNameComparator(const IndexedDBInfo& i, const IndexedDBInfo& j) {
}
void IndexedDBInternalsUI::GetAllOriginsOnWebkitThread(
- scoped_refptr<IndexedDBContext> context) {
+ scoped_ptr<ContextList> contexts,
+ scoped_ptr<std::vector<base::FilePath> > context_paths) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
-
- scoped_ptr<std::vector<IndexedDBInfo> > origins(
- new std::vector<IndexedDBInfo>(context->GetAllOriginsInfo()));
- std::sort(origins->begin(), origins->end(), HostNameComparator);
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&IndexedDBInternalsUI::OnOriginsReady, base::Unretained(this),
- base::Passed(&origins)));
+ DCHECK_EQ(contexts->size(), context_paths->size());
jsbell 2013/04/12 21:25:59 As discussed offline, an alternative would be to m
+
+ std::vector<base::FilePath>::const_iterator path_iter =
+ context_paths->begin();
+ for (ContextList::const_iterator iter = contexts->begin();
jsbell 2013/04/12 21:25:59 ... although it would make this dual-iteration sli
+ iter != contexts->end(); ++iter) {
michaeln 2013/04/12 23:00:31 nit: would dbl-iter be more clear with ++iter, ++p
+ IndexedDBContext* context = *iter;
+ const base::FilePath& context_path = *path_iter;
+
+ scoped_ptr<std::vector<IndexedDBInfo> > info_list(
+ new std::vector<IndexedDBInfo>(context->GetAllOriginsInfo()));
+ std::sort(info_list->begin(), info_list->end(), HostNameComparator);
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&IndexedDBInternalsUI::OnOriginsReady,
+ base::Unretained(this),
+ base::Passed(&info_list),
+ context_path));
+ ++path_iter;
+ }
}
void IndexedDBInternalsUI::OnOriginsReady(
- scoped_ptr<std::vector<IndexedDBInfo> > origins) {
+ scoped_ptr<std::vector<IndexedDBInfo> > origins,
+ const base::FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::ListValue urls;
for (std::vector<IndexedDBInfo>::const_iterator iter = origins->begin();
@@ -92,8 +118,11 @@ void IndexedDBInternalsUI::OnOriginsReady(
info->SetString("url", iter->origin.spec());
info->SetDouble("size", iter->size);
info->SetDouble("last_modified", iter->last_modified.ToJsTime());
+ info->SetString("path", iter->path.value());
urls.Append(info);
}
- web_ui()->CallJavascriptFunction("indexeddb.onOriginsReady", urls);
+ web_ui()->CallJavascriptFunction("indexeddb.onOriginsReady",
+ urls,
+ base::StringValue(path.value()));
}
}

Powered by Google App Engine
This is Rietveld 408576698