Commit f9e60c3c authored by tzik@chromium.org's avatar tzik@chromium.org

[SyncFS] Add TaskLog tab on chrome://syncfs-internals

BUG=

Review URL: https://codereview.chromium.org/304993004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274285 0039d316-1c4b-4281-b951-d872f2087c98
parent d4975248
...@@ -40,6 +40,28 @@ tbody tr:nth-child(odd) { ...@@ -40,6 +40,28 @@ tbody tr:nth-child(odd) {
background: rgb(255, 220, 220); background: rgb(255, 220, 220);
} }
.task-log-details label {
cursor: pointer;
}
.task-log-collapse-check {
vertical-align: top;
}
.task-log-collapse-check ~ ul {
display: inline-block;
height: 1em;
list-style: none;
margin: 0;
overflow: hidden;
padding: 0;
position: relative;
}
.task-log-collapse-check:checked ~ ul {
height: auto;
}
.file-icon { .file-icon {
background-image: url('chrome://syncfs-internals/file.png'); background-image: url('chrome://syncfs-internals/file.png');
background-position: 0 2px; background-position: 0 2px;
......
...@@ -25,6 +25,7 @@ found in the LICENSE file. ...@@ -25,6 +25,7 @@ found in the LICENSE file.
<tabbox> <tabbox>
<tabs> <tabs>
<tab>Sync Service</tab> <tab>Sync Service</tab>
<tab>Task Log</tab>
<tab>Extension Statuses</tab> <tab>Extension Statuses</tab>
<tab>File Metadata</tab> <tab>File Metadata</tab>
<tab>Database Dump</tab> <tab>Database Dump</tab>
...@@ -33,6 +34,9 @@ found in the LICENSE file. ...@@ -33,6 +34,9 @@ found in the LICENSE file.
<tabpanel> <tabpanel>
<include src="sync_service.html" /> <include src="sync_service.html" />
</tabpanel> </tabpanel>
<tabpanel>
<include src="task_log.html" />
</tabpanel>
<tabpanel> <tabpanel>
<include src="extension_statuses.html" /> <include src="extension_statuses.html" />
</tabpanel> </tabpanel>
......
...@@ -69,9 +69,9 @@ SyncService.onGetLog = function(logEntries) { ...@@ -69,9 +69,9 @@ SyncService.onGetLog = function(logEntries) {
var tr = document.createElement('tr'); var tr = document.createElement('tr');
var error = /ERROR/.test(logEntry.logEvent) ? ' error' : ''; var error = /ERROR/.test(logEntry.logEvent) ? ' error' : '';
tr.appendChild(createElementFromText('td', logEntry.time, tr.appendChild(createElementFromText('td', logEntry.time,
{class: 'log-time'})); {'class': 'log-time'}));
tr.appendChild(createElementFromText('td', logEntry.logEvent, tr.appendChild(createElementFromText('td', logEntry.logEvent,
{class: 'log-event' + error})); {'class': 'log-event' + error}));
itemContainer.appendChild(tr); itemContainer.appendChild(tr);
lastLogEventId = logEntry.id; lastLogEventId = logEntry.id;
......
<script src="chrome://syncfs-internals/task_log.js"></script>
<h3>Task Log</h3>
<table>
<thead>
<tr>
<td>Duration</td>
<td>Task</td>
<td>Result</td>
<td>Details</td>
</tr>
</thead>
<tbody id="task-log-entries"></tbody>
</table>
// Copyright 2014 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.
var TaskLog = (function() {
'use strict';
var nextTaskLogSeq = 1;
var TaskLog = {};
function observeTaskLog() {
chrome.send('observeTaskLog');
}
/**
* Handles per-task log event.
* @param {Object} taskLog a dictionary containing 'duration',
* 'task_description', 'result_description' and 'details'.
*/
TaskLog.onTaskLogRecorded = function(taskLog) {
var details = document.createElement('td');
details.classList.add('task-log-details');
var label = document.createElement('label');
details.appendChild(label);
var collapseCheck = document.createElement('input');
collapseCheck.setAttribute('type', 'checkbox');
collapseCheck.classList.add('task-log-collapse-check');
label.appendChild(collapseCheck);
var ul = document.createElement('ul');
for (var i = 0; i < taskLog.details.length; ++i)
ul.appendChild(createElementFromText('li', taskLog.details[i]));
label.appendChild(ul);
var tr = document.createElement('tr');
tr.appendChild(createElementFromText(
'td', taskLog.duration, {'class': 'task-log-duration'}));
tr.appendChild(createElementFromText(
'td', taskLog.task_description, {'class': 'task-log-description'}));
tr.appendChild(createElementFromText(
'td', taskLog.result_description, {'class': 'task-log-result'}));
tr.appendChild(details);
$('task-log-entries').appendChild(tr);
}
/**
* Get initial sync service values and set listeners to get updated values.
*/
function main() {
observeTaskLog();
}
document.addEventListener('DOMContentLoaded', main);
return TaskLog;
})();
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS" file="sync_file_system_internals/dump_database.js" type="BINDATA" /> <include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS" file="sync_file_system_internals/dump_database.js" type="BINDATA" />
<include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_MAIN_HTML" file="sync_file_system_internals/main.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_MAIN_HTML" file="sync_file_system_internals/main.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS" file="sync_file_system_internals/sync_service.js" type="BINDATA" /> <include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS" file="sync_file_system_internals/sync_service.js" type="BINDATA" />
<include name="IDR_SYNC_FILE_SYSTEM_INTERNALS_TASK_LOG_JS" file="sync_file_system_internals/task_log.js" type="BINDATA" />
</includes> </includes>
</release> </release>
</grit> </grit>
...@@ -324,8 +324,6 @@ void SyncTaskManager::RunTask(scoped_ptr<SyncTaskToken> token, ...@@ -324,8 +324,6 @@ void SyncTaskManager::RunTask(scoped_ptr<SyncTaskToken> token,
scoped_ptr<SyncTask> task) { scoped_ptr<SyncTask> task) {
DCHECK(!running_foreground_task_); DCHECK(!running_foreground_task_);
token->SetTaskLog(make_scoped_ptr(new TaskLogger::TaskLog));
running_foreground_task_ = task.Pass(); running_foreground_task_ = task.Pass();
running_foreground_task_->RunPreflight(token.Pass()); running_foreground_task_->RunPreflight(token.Pass());
} }
......
...@@ -95,6 +95,7 @@ void SyncTaskToken::clear_blocking_factor() { ...@@ -95,6 +95,7 @@ void SyncTaskToken::clear_blocking_factor() {
void SyncTaskToken::InitializeTaskLog(const std::string& task_description) { void SyncTaskToken::InitializeTaskLog(const std::string& task_description) {
DCHECK(task_log_); DCHECK(task_log_);
task_log_.reset(new TaskLogger::TaskLog);
task_log_->start_time = base::TimeTicks::Now(); task_log_->start_time = base::TimeTicks::Now();
task_log_->task_description = task_description; task_log_->task_description = task_description;
} }
......
...@@ -24,6 +24,9 @@ TaskLogger::~TaskLogger() { ...@@ -24,6 +24,9 @@ TaskLogger::~TaskLogger() {
} }
void TaskLogger::RecordLog(scoped_ptr<TaskLog> log) { void TaskLogger::RecordLog(scoped_ptr<TaskLog> log) {
if (!log)
return;
if (log_history_.size() >= kMaxLogSize) { if (log_history_.size() >= kMaxLogSize) {
delete log_history_.front(); delete log_history_.front();
log_history_.pop_front(); log_history_.pop_front();
......
...@@ -102,7 +102,7 @@ void SyncFileSystemInternalsHandler::OnLogRecorded( ...@@ -102,7 +102,7 @@ void SyncFileSystemInternalsHandler::OnLogRecorded(
scoped_ptr<base::ListValue> details(new base::ListValue); scoped_ptr<base::ListValue> details(new base::ListValue);
details->AppendStrings(task_log.details); details->AppendStrings(task_log.details);
dict.Set("details", details.release()); dict.Set("details", details.release());
web_ui()->CallJavascriptFunction("SyncService.onTaskLogRecorded", dict); web_ui()->CallJavascriptFunction("TaskLog.onTaskLogRecorded", dict);
} }
void SyncFileSystemInternalsHandler::GetServiceStatus( void SyncFileSystemInternalsHandler::GetServiceStatus(
...@@ -174,11 +174,12 @@ void SyncFileSystemInternalsHandler::ObserveTaskLog( ...@@ -174,11 +174,12 @@ void SyncFileSystemInternalsHandler::ObserveTaskLog(
if (!observing_task_log_) { if (!observing_task_log_) {
observing_task_log_ = true; observing_task_log_ = true;
sync_service->task_logger()->AddObserver(this); sync_service->task_logger()->AddObserver(this);
return;
} }
DCHECK(sync_service->task_logger());
const sync_file_system::TaskLogger::LogList& log = const sync_file_system::TaskLogger::LogList& log =
sync_service->task_logger()->GetLog(); sync_service->task_logger()->GetLog();
for (sync_file_system::TaskLogger::LogList::const_iterator itr = log.begin(); for (sync_file_system::TaskLogger::LogList::const_iterator itr = log.begin();
itr != log.end(); ++itr) itr != log.end(); ++itr)
OnLogRecorded(**itr); OnLogRecorded(**itr);
......
...@@ -32,6 +32,8 @@ content::WebUIDataSource* CreateSyncFileSystemInternalsHTMLSource() { ...@@ -32,6 +32,8 @@ content::WebUIDataSource* CreateSyncFileSystemInternalsHTMLSource() {
"file_metadata.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_FILE_METADATA_JS); "file_metadata.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_FILE_METADATA_JS);
source->AddResourcePath( source->AddResourcePath(
"sync_service.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS); "sync_service.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS);
source->AddResourcePath(
"task_log.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_TASK_LOG_JS);
source->AddResourcePath( source->AddResourcePath(
"dump_database.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS); "dump_database.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS);
source->AddResourcePath("file.png", IDR_DEFAULT_FAVICON); source->AddResourcePath("file.png", IDR_DEFAULT_FAVICON);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment