blob: 7aba8d97af7a5f8b5e7829abee4c2700a36b635d [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2020 The Chromium Authors
Rushan Suleymanov4f66fa02020-01-21 14:12:302// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Hira Mahmood538940952024-06-12 08:31:155#ifndef COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_
6#define COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_
Rushan Suleymanov4f66fa02020-01-21 14:12:307
8#include <memory>
9
Avi Drissman9269d4ed2023-01-07 01:38:0610#include "base/functional/callback.h"
Rushan Suleymanovb32520d2020-01-23 11:35:1211#include "base/memory/weak_ptr.h"
12#include "components/keyed_service/core/keyed_service.h"
Rushan Suleymanov4f66fa02020-01-21 14:12:3013#include "components/sync/protocol/sharing_message_specifics.pb.h"
14
Rushan Suleymanovb32520d2020-01-23 11:35:1215namespace syncer {
Mikel Astiz07a3db92024-08-02 06:10:1116class DataTypeControllerDelegate;
Rushan Suleymanovb32520d2020-01-23 11:35:1217} // namespace syncer
18
Rushan Suleymanov4f66fa02020-01-21 14:12:3019// Class to provide an interface to send sharing messages using Sync.
Rushan Suleymanovb32520d2020-01-23 11:35:1220class SharingMessageBridge : public KeyedService {
Rushan Suleymanov4f66fa02020-01-21 14:12:3021 public:
Rushan Suleymanov3fda733e2020-01-23 15:41:4022 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 Gale079e6e952024-04-16 22:00:3027 // TODO(crbug.com/40111980): take each parameter separately and construct
Rushan Suleymanov86d179a2020-01-23 12:52:3528 // specifics inside. Currently this method updates given |specifics| and
29 // fills in |message_id| field.
Rushan Suleymanov4f66fa02020-01-21 14:12:3030 virtual void SendSharingMessage(
Rushan Suleymanov3fda733e2020-01-23 15:41:4031 std::unique_ptr<sync_pb::SharingMessageSpecifics> specifics,
32 CommitFinishedCallback on_commit_callback) = 0;
Rushan Suleymanov4f66fa02020-01-21 14:12:3033
Rushan Suleymanovb32520d2020-01-23 11:35:1234 // Returns the delegate for the controller, i.e. sync integration point.
Mikel Astiz07a3db92024-08-02 06:10:1135 virtual base::WeakPtr<syncer::DataTypeControllerDelegate>
Rushan Suleymanovb32520d2020-01-23 11:35:1236 GetControllerDelegate() = 0;
Rushan Suleymanov4f66fa02020-01-21 14:12:3037};
38
Hira Mahmood538940952024-06-12 08:31:1539#endif // COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_