blob: 3eb2e4cc5f66ec61bd6007051a2e3de89528bb67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync_file_system/sync_file_system_service.h"
#include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
using sync_file_system::SyncFileSystemServiceFactory;
namespace syncfs_internals {
DumpDatabaseHandler::DumpDatabaseHandler(Profile* profile)
: profile_(profile) {}
DumpDatabaseHandler::~DumpDatabaseHandler() {}
void DumpDatabaseHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getDatabaseDump",
base::Bind(&DumpDatabaseHandler::GetDatabaseDump,
base::Unretained(this)));
}
void DumpDatabaseHandler::GetDatabaseDump(const base::ListValue*) {
scoped_ptr<base::ListValue> list;
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile_);
if (sync_service) {
sync_service->DumpDatabase(
base::Bind(&DumpDatabaseHandler::DidGetDatabaseDump,
base::Unretained(this)));
}
}
void DumpDatabaseHandler::DidGetDatabaseDump(const base::ListValue& list) {
web_ui()->CallJavascriptFunction("DumpDatabase.onGetDatabaseDump", list);
}
} // namespace syncfs_internals
|