blob: e7f79bbf0602f51f6a93a1ed34a8d1d7e3f166f5 [file] [log] [blame]
// 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.
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "components/sync/model/data_type_error_handler.h"
namespace syncer {
// The standard implementation of DataTypeErrorHandler.
class DataTypeErrorHandlerImpl : public DataTypeErrorHandler {
using ErrorCallback = base::Callback<void(const SyncError&)>;
const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
const base::Closure& dump_stack,
const ErrorCallback& sync_callback);
~DataTypeErrorHandlerImpl() override;
void OnUnrecoverableError(const SyncError& error) override;
SyncError CreateAndUploadError(const base::Location& location,
const std::string& message,
ModelType type) override;
std::unique_ptr<DataTypeErrorHandler> Copy() const override;
// The thread task runner that |sync_callback_| runs on. This is passed in
// separately instead of bound inside the callback because we want to be able
// to perform the PostTask using the error location.
scoped_refptr<base::SequencedTaskRunner> ui_thread_;
// The callback to dump and upload the stack from the current thread.
base::Closure dump_stack_;
// The callback used to inform sync of the error on the |ui_thread_|.
ErrorCallback sync_callback_;
} // namespace syncer