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

[SyncFS] Wire TaskLogger to SyncTaskToken and SyncTaskManager

BUG=344769

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273175 0039d316-1c4b-4281-b951-d872f2087c98
parent 3edebd95
......@@ -155,6 +155,7 @@ void SyncTaskManager::UpdateBlockingFactor(
scoped_ptr<SyncTaskToken> foreground_task_token;
scoped_ptr<SyncTaskToken> background_task_token;
scoped_ptr<TaskLogger::TaskLog> task_log = current_task_token->PassTaskLog();
if (current_task_token->token_id() == SyncTaskToken::kForegroundTaskTokenID)
foreground_task_token = current_task_token.Pass();
else
......@@ -162,6 +163,7 @@ void SyncTaskManager::UpdateBlockingFactor(
manager->UpdateBlockingFactorBody(foreground_task_token.Pass(),
background_task_token.Pass(),
task_log.Pass(),
blocking_factor.Pass(),
continuation);
}
......@@ -190,7 +192,8 @@ void SyncTaskManager::NotifyTaskDoneBody(scoped_ptr<SyncTaskToken> token,
token->clear_blocking_factor();
}
// TODO(tzik): Record TaskLog to |client_| here.
if (client_)
client_->RecordTaskLog(token->PassTaskLog());
scoped_ptr<SyncTask> task;
SyncStatusCallback callback = token->callback();
......@@ -218,6 +221,7 @@ void SyncTaskManager::NotifyTaskDoneBody(scoped_ptr<SyncTaskToken> token,
void SyncTaskManager::UpdateBlockingFactorBody(
scoped_ptr<SyncTaskToken> foreground_task_token,
scoped_ptr<SyncTaskToken> background_task_token,
scoped_ptr<TaskLogger::TaskLog> task_log,
scoped_ptr<BlockingFactor> blocking_factor,
const Continuation& continuation) {
// Run the task directly if the parallelization is disabled.
......@@ -247,6 +251,7 @@ void SyncTaskManager::UpdateBlockingFactorBody(
AsWeakPtr(),
base::Passed(&foreground_task_token),
base::Passed(&background_task_token),
base::Passed(&task_log),
base::Passed(&blocking_factor),
continuation),
PRIORITY_HIGH);
......@@ -272,6 +277,7 @@ void SyncTaskManager::UpdateBlockingFactorBody(
AsWeakPtr(),
base::Passed(&foreground_task_token),
base::Passed(&background_task_token),
base::Passed(&task_log),
base::Passed(&blocking_factor),
continuation);
return;
......@@ -296,6 +302,7 @@ void SyncTaskManager::UpdateBlockingFactorBody(
token_ = foreground_task_token.Pass();
StartNextTask();
background_task_token->SetTaskLog(task_log.Pass());
continuation.Run(background_task_token.Pass());
}
......@@ -316,6 +323,9 @@ void SyncTaskManager::PushPendingTask(
void SyncTaskManager::RunTask(scoped_ptr<SyncTaskToken> token,
scoped_ptr<SyncTask> task) {
DCHECK(!running_foreground_task_);
token->SetTaskLog(make_scoped_ptr(new TaskLogger::TaskLog));
running_foreground_task_ = task.Pass();
running_foreground_task_->RunPreflight(token.Pass());
}
......
......@@ -141,6 +141,7 @@ class SyncTaskManager
// Non-static version of UpdateBlockingFactor.
void UpdateBlockingFactorBody(scoped_ptr<SyncTaskToken> foreground_task_token,
scoped_ptr<SyncTaskToken> background_task_token,
scoped_ptr<TaskLogger::TaskLog> task_log,
scoped_ptr<BlockingFactor> blocking_factor,
const Continuation& continuation);
......
......@@ -93,6 +93,31 @@ void SyncTaskToken::clear_blocking_factor() {
blocking_factor_.reset();
}
void SyncTaskToken::InitializeTaskLog(const std::string& task_description) {
DCHECK(task_log_);
task_log_->start_time = base::TimeTicks::Now();
task_log_->task_description = task_description;
}
void SyncTaskToken::FinalizeTaskLog(const std::string& result_description) {
DCHECK(task_log_);
task_log_->result_description = result_description;
task_log_->end_time = base::TimeTicks::Now();
}
void SyncTaskToken::RecordLog(const std::string& message) {
DCHECK(task_log_);
task_log_->details.push_back(message);
}
void SyncTaskToken::SetTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) {
task_log_ = task_log.Pass();
}
scoped_ptr<TaskLogger::TaskLog> SyncTaskToken::PassTaskLog() {
return task_log_.Pass();
}
SyncTaskToken::SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager,
int64 token_id,
scoped_ptr<BlockingFactor> blocking_factor,
......
......@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sync_file_system/sync_callbacks.h"
#include "chrome/browser/sync_file_system/task_logger.h"
namespace sync_file_system {
namespace drive_backend {
......@@ -53,6 +54,13 @@ class SyncTaskToken {
int64 token_id() const { return token_id_; }
void InitializeTaskLog(const std::string& task_description);
void FinalizeTaskLog(const std::string& result_description);
void RecordLog(const std::string& message);
void SetTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log);
scoped_ptr<TaskLogger::TaskLog> PassTaskLog();
private:
SyncTaskToken(const base::WeakPtr<SyncTaskManager>& manager,
int64 token_id,
......@@ -64,6 +72,7 @@ class SyncTaskToken {
int64 token_id_;
SyncStatusCallback callback_;
scoped_ptr<TaskLogger::TaskLog> task_log_;
scoped_ptr<BlockingFactor> blocking_factor_;
DISALLOW_COPY_AND_ASSIGN(SyncTaskToken);
......
......@@ -18,9 +18,10 @@ namespace sync_file_system {
class TaskLogger : public base::SupportsWeakPtr<TaskLogger> {
public:
struct TaskLog {
base::TimeDelta duration;
std::string type;
std::string summary;
base::TimeTicks start_time;
base::TimeTicks end_time;
std::string task_description;
std::string result_description;
std::vector<std::string> details;
TaskLog();
......
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