OLD | NEW |
| (Empty) |
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 | |
5 #ifndef COMPONENTS_SYNC_API_DATA_TYPE_ERROR_HANDLER_IMPL_H__ | |
6 #define COMPONENTS_SYNC_API_DATA_TYPE_ERROR_HANDLER_IMPL_H__ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/ptr_util.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/single_thread_task_runner.h" | |
15 #include "components/sync/api/data_type_error_handler.h" | |
16 | |
17 namespace syncer { | |
18 | |
19 // The standard implementation of DataTypeErrorHandler. | |
20 class DataTypeErrorHandlerImpl : public DataTypeErrorHandler { | |
21 public: | |
22 typedef base::Callback<void(const SyncError&)> ErrorCallback; | |
23 | |
24 DataTypeErrorHandlerImpl( | |
25 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | |
26 const base::Closure& dump_stack, | |
27 const ErrorCallback& sync_callback); | |
28 ~DataTypeErrorHandlerImpl() override; | |
29 | |
30 void OnUnrecoverableError(const SyncError& error) override; | |
31 SyncError CreateAndUploadError(const tracked_objects::Location& location, | |
32 const std::string& message, | |
33 ModelType type) override; | |
34 std::unique_ptr<DataTypeErrorHandler> Copy() const override; | |
35 | |
36 private: | |
37 // The thread task runner that |sync_callback_| runs on. This is passed in | |
38 // separately instead of bound inside the callback because we want to be able | |
39 // to perform the PostTask using the error location. | |
40 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | |
41 | |
42 // The callback to dump and upload the stack from the current thread. | |
43 base::Closure dump_stack_; | |
44 | |
45 // The callback used to inform sync of the error on the |ui_thread_|. | |
46 ErrorCallback sync_callback_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(DataTypeErrorHandlerImpl); | |
49 }; | |
50 | |
51 } // namespace syncer | |
52 | |
53 #endif // COMPONENTS_SYNC_API_DATA_TYPE_ERROR_HANDLER_IMPL_H__ | |
OLD | NEW |