Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Hira Mahmood | 53894095 | 2024-06-12 08:31:15 | [diff] [blame] | 5 | #ifndef COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_ |
| 6 | #define COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_ |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | |
Avi Drissman | 9269d4ed | 2023-01-07 01:38:06 | [diff] [blame] | 10 | #include "base/functional/callback.h" |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
| 12 | #include "components/keyed_service/core/keyed_service.h" |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 13 | #include "components/sync/protocol/sharing_message_specifics.pb.h" |
| 14 | |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 15 | namespace syncer { |
Mikel Astiz | 07a3db9 | 2024-08-02 06:10:11 | [diff] [blame] | 16 | class DataTypeControllerDelegate; |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 17 | } // namespace syncer |
| 18 | |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 19 | // Class to provide an interface to send sharing messages using Sync. |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 20 | class SharingMessageBridge : public KeyedService { |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 21 | public: |
Rushan Suleymanov | 3fda733e | 2020-01-23 15:41:40 | [diff] [blame] | 22 | using CommitFinishedCallback = |
| 23 | base::OnceCallback<void(const sync_pb::SharingMessageCommitError&)>; |
| 24 | |
| 25 | // Sends Sharing Message to Sync server. |on_commit_callback| will be called |
| 26 | // when commit attempt finishes (either successfully or unsuccessfully). |
Alison Gale | 079e6e95 | 2024-04-16 22:00:30 | [diff] [blame] | 27 | // TODO(crbug.com/40111980): take each parameter separately and construct |
Rushan Suleymanov | 86d179a | 2020-01-23 12:52:35 | [diff] [blame] | 28 | // specifics inside. Currently this method updates given |specifics| and |
| 29 | // fills in |message_id| field. |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 30 | virtual void SendSharingMessage( |
Rushan Suleymanov | 3fda733e | 2020-01-23 15:41:40 | [diff] [blame] | 31 | std::unique_ptr<sync_pb::SharingMessageSpecifics> specifics, |
| 32 | CommitFinishedCallback on_commit_callback) = 0; |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 33 | |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 34 | // Returns the delegate for the controller, i.e. sync integration point. |
Mikel Astiz | 07a3db9 | 2024-08-02 06:10:11 | [diff] [blame] | 35 | virtual base::WeakPtr<syncer::DataTypeControllerDelegate> |
Rushan Suleymanov | b32520d | 2020-01-23 11:35:12 | [diff] [blame] | 36 | GetControllerDelegate() = 0; |
Rushan Suleymanov | 4f66fa0 | 2020-01-21 14:12:30 | [diff] [blame] | 37 | }; |
| 38 | |
Hira Mahmood | 53894095 | 2024-06-12 08:31:15 | [diff] [blame] | 39 | #endif // COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_ |