#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
-#include "chrome/browser/chromeos/drive/logging.h"
+#include "chrome/browser/drive/event_logger.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/drive_api_parser.h"
base::FilePath local_file_path;
std::string title;
std::string content_type;
+ DriveUploader::UploadNewFileOptions options;
UploadCompletionCallback callback;
google_apis::ProgressCallback progress_callback;
};
params.local_file_path,
params.title,
params.content_type,
- DriveUploader::UploadNewFileOptions(),
+ params.options,
params.callback,
params.progress_callback);
}
std::string resource_id;
base::FilePath local_file_path;
std::string content_type;
- drive::DriveUploader::UploadExistingFileOptions options;
+ DriveUploader::UploadExistingFileOptions options;
std::string etag;
UploadCompletionCallback callback;
google_apis::ProgressCallback progress_callback;
JobScheduler::JobScheduler(
PrefService* pref_service,
+ EventLogger* logger,
DriveServiceInterface* drive_service,
base::SequencedTaskRunner* blocking_task_runner)
: throttle_count_(0),
wait_until_(base::Time::Now()),
disable_throttling_(false),
+ logger_(logger),
drive_service_(drive_service),
uploader_(new DriveUploader(drive_service, blocking_task_runner)),
pref_service_(pref_service),
void JobScheduler::AddNewDirectory(
const std::string& parent_resource_id,
const std::string& directory_title,
+ const DriveServiceInterface::AddNewDirectoryOptions& options,
+ const ClientContext& context,
const google_apis::GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
JobEntry* new_job = CreateNewJob(TYPE_ADD_NEW_DIRECTORY);
+ new_job->context = context;
new_job->task = base::Bind(
&DriveServiceInterface::AddNewDirectory,
base::Unretained(drive_service_),
parent_resource_id,
directory_title,
+ options,
base::Bind(&JobScheduler::OnGetResourceEntryJobDone,
weak_ptr_factory_.GetWeakPtr(),
new_job->job_info.job_id,
const base::FilePath& local_file_path,
const std::string& title,
const std::string& content_type,
+ const DriveUploader::UploadNewFileOptions& options,
const ClientContext& context,
const google_apis::GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
params.local_file_path = local_file_path;
params.title = title;
params.content_type = content_type;
+ params.options = options;
ResumeUploadParams resume_params;
resume_params.local_file_path = params.local_file_path;
const base::FilePath& drive_file_path,
const base::FilePath& local_file_path,
const std::string& content_type,
- const drive::DriveUploader::UploadExistingFileOptions& options,
+ const DriveUploader::UploadExistingFileOptions& options,
const ClientContext& context,
const google_apis::GetResourceEntryCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
StartJob(new_job);
}
-void JobScheduler::CreateFile(
- const std::string& parent_resource_id,
- const base::FilePath& drive_file_path,
- const std::string& title,
- const std::string& content_type,
- const ClientContext& context,
- const google_apis::GetResourceEntryCallback& callback) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- const base::FilePath kDevNull(FILE_PATH_LITERAL("/dev/null"));
-
- JobEntry* new_job = CreateNewJob(TYPE_CREATE_FILE);
- new_job->job_info.file_path = drive_file_path;
- new_job->context = context;
-
- UploadNewFileParams params;
- params.parent_resource_id = parent_resource_id;
- params.local_file_path = kDevNull; // Upload an empty file.
- params.title = title;
- params.content_type = content_type;
-
- ResumeUploadParams resume_params;
- resume_params.local_file_path = params.local_file_path;
- resume_params.content_type = params.content_type;
-
- params.callback = base::Bind(&JobScheduler::OnUploadCompletionJobDone,
- weak_ptr_factory_.GetWeakPtr(),
- new_job->job_info.job_id,
- resume_params,
- callback);
- params.progress_callback = google_apis::ProgressCallback();
-
- new_job->task = base::Bind(&RunUploadNewFile, uploader_.get(), params);
- new_job->abort_callback = CreateErrorRunCallback(callback);
- StartJob(new_job);
-}
-
void JobScheduler::GetResourceListInDirectoryByWapi(
const std::string& directory_resource_id,
const google_apis::GetResourceListCallback& callback) {
const std::string retry_prefix = job_entry->retry_count > 0 ?
base::StringPrintf(" (retry %d)", job_entry->retry_count) : "";
- util::Log(logging::LOG_INFO,
- "Job queued%s: %s - %s",
- retry_prefix.c_str(),
- job_info.ToString().c_str(),
- GetQueueInfo(queue_type).c_str());
+ logger_->Log(logging::LOG_INFO,
+ "Job queued%s: %s - %s",
+ retry_prefix.c_str(),
+ job_info.ToString().c_str(),
+ GetQueueInfo(queue_type).c_str());
}
void JobScheduler::DoJobLoop(QueueType queue_type) {
UpdateWait();
- util::Log(logging::LOG_INFO,
- "Job started: %s - %s",
- job_info->ToString().c_str(),
- GetQueueInfo(queue_type).c_str());
+ logger_->Log(logging::LOG_INFO,
+ "Job started: %s - %s",
+ job_info->ToString().c_str(),
+ GetQueueInfo(queue_type).c_str());
}
int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) {
const base::TimeDelta elapsed = base::Time::Now() - job_info->start_time;
bool success = (GDataToFileError(error) == FILE_ERROR_OK);
- util::Log(success ? logging::LOG_INFO : logging::LOG_WARNING,
- "Job done: %s => %s (elapsed time: %sms) - %s",
- job_info->ToString().c_str(),
- GDataErrorCodeToString(error).c_str(),
- base::Int64ToString(elapsed.InMilliseconds()).c_str(),
- GetQueueInfo(queue_type).c_str());
+ logger_->Log(success ? logging::LOG_INFO : logging::LOG_WARNING,
+ "Job done: %s => %s (elapsed time: %sms) - %s",
+ job_info->ToString().c_str(),
+ GDataErrorCodeToString(error).c_str(),
+ base::Int64ToString(elapsed.InMilliseconds()).c_str(),
+ GetQueueInfo(queue_type).c_str());
// Retry, depending on the error.
const bool is_server_error =
const base::TimeDelta elapsed = base::Time::Now() - job->job_info.start_time;
const QueueType queue_type = GetJobQueueType(job->job_info.job_type);
- util::Log(logging::LOG_INFO,
- "Job aborted: %s => %s (elapsed time: %sms) - %s",
- job->job_info.ToString().c_str(),
- GDataErrorCodeToString(error).c_str(),
- base::Int64ToString(elapsed.InMilliseconds()).c_str(),
- GetQueueInfo(queue_type).c_str());
+ logger_->Log(logging::LOG_INFO,
+ "Job aborted: %s => %s (elapsed time: %sms) - %s",
+ job->job_info.ToString().c_str(),
+ GDataErrorCodeToString(error).c_str(),
+ base::Int64ToString(elapsed.InMilliseconds()).c_str(),
+ GetQueueInfo(queue_type).c_str());
base::Callback<void(google_apis::GDataErrorCode)> callback =
job->abort_callback;