data_type_error_handler_impl.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_MODEL_DATA_TYPE_ERROR_HANDLER_IMPL_H__
  5. #define COMPONENTS_SYNC_MODEL_DATA_TYPE_ERROR_HANDLER_IMPL_H__
  6. #include <memory>
  7. #include <string>
  8. #include "base/memory/ref_counted.h"
  9. #include "base/task/sequenced_task_runner.h"
  10. #include "components/sync/model/data_type_error_handler.h"
  11. namespace syncer {
  12. // The standard implementation of DataTypeErrorHandler.
  13. class DataTypeErrorHandlerImpl : public DataTypeErrorHandler {
  14. public:
  15. using ErrorCallback = base::RepeatingCallback<void(const SyncError&)>;
  16. DataTypeErrorHandlerImpl(
  17. const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
  18. const base::RepeatingClosure& dump_stack,
  19. const ErrorCallback& sync_callback);
  20. DataTypeErrorHandlerImpl(const DataTypeErrorHandlerImpl&) = delete;
  21. DataTypeErrorHandlerImpl& operator=(const DataTypeErrorHandlerImpl&) = delete;
  22. ~DataTypeErrorHandlerImpl() override;
  23. void OnUnrecoverableError(const SyncError& error) override;
  24. SyncError CreateAndUploadError(const base::Location& location,
  25. const std::string& message,
  26. ModelType type) override;
  27. std::unique_ptr<DataTypeErrorHandler> Copy() const override;
  28. private:
  29. // The thread task runner that |sync_callback_| runs on. This is passed in
  30. // separately instead of bound inside the callback because we want to be able
  31. // to perform the PostTask using the error location.
  32. scoped_refptr<base::SequencedTaskRunner> ui_thread_;
  33. // The callback to dump and upload the stack from the current thread.
  34. base::RepeatingClosure dump_stack_;
  35. // The callback used to inform sync of the error on the |ui_thread_|.
  36. ErrorCallback sync_callback_;
  37. };
  38. } // namespace syncer
  39. #endif // COMPONENTS_SYNC_MODEL_DATA_TYPE_ERROR_HANDLER_IMPL_H__