Add ability to gather metrics to BubbleManager.
[chromium-blink-merge.git] / chrome / browser / ui / webui / sync_file_system_internals / dump_database_handler.cc
blob3eb2e4cc5f66ec61bd6007051a2e3de89528bb67
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
9 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
10 #include "content/public/browser/web_ui.h"
11 #include "content/public/browser/web_ui_data_source.h"
13 using sync_file_system::SyncFileSystemServiceFactory;
15 namespace syncfs_internals {
17 DumpDatabaseHandler::DumpDatabaseHandler(Profile* profile)
18 : profile_(profile) {}
19 DumpDatabaseHandler::~DumpDatabaseHandler() {}
21 void DumpDatabaseHandler::RegisterMessages() {
22 web_ui()->RegisterMessageCallback(
23 "getDatabaseDump",
24 base::Bind(&DumpDatabaseHandler::GetDatabaseDump,
25 base::Unretained(this)));
28 void DumpDatabaseHandler::GetDatabaseDump(const base::ListValue*) {
29 scoped_ptr<base::ListValue> list;
30 sync_file_system::SyncFileSystemService* sync_service =
31 SyncFileSystemServiceFactory::GetForProfile(profile_);
32 if (sync_service) {
33 sync_service->DumpDatabase(
34 base::Bind(&DumpDatabaseHandler::DidGetDatabaseDump,
35 base::Unretained(this)));
39 void DumpDatabaseHandler::DidGetDatabaseDump(const base::ListValue& list) {
40 web_ui()->CallJavascriptFunction("DumpDatabase.onGetDatabaseDump", list);
43 } // namespace syncfs_internals