Commit 1f13d955 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS PhoneHub] Refactor NearbyConnections to support multiple Cores

Each Core object is meant to be used by a single client, so we will use
one for Nearby Share and one for Phone Hub. Each Core instance uses the
same underlying connectivity framework, so we instantiate a single
OfflineServiceController and share it with all Cores.

This CL also adds a service_id parameter to each
mojom::NearbyConnections function so that we can decide which Core
object to use to process each call.

Bug: 1106937
Change-Id: Ibbf8378822862579b79321689dd00a61d204fb1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495878Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824962}
parent 875685e6
...@@ -98,7 +98,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising( ...@@ -98,7 +98,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
incoming_connection_listener_ = listener; incoming_connection_listener_ = listener;
nearby_connections_->StartAdvertising( nearby_connections_->StartAdvertising(
endpoint_info, kServiceId, kServiceId, endpoint_info,
AdvertisingOptions::New( AdvertisingOptions::New(
kStrategy, std::move(allowed_mediums), kStrategy, std::move(allowed_mediums),
/*auto_upgrade_bandwidth=*/is_high_power, /*auto_upgrade_bandwidth=*/is_high_power,
...@@ -112,7 +112,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising( ...@@ -112,7 +112,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
void NearbyConnectionsManagerImpl::StopAdvertising() { void NearbyConnectionsManagerImpl::StopAdvertising() {
if (nearby_connections_) { if (nearby_connections_) {
nearby_connections_->StopAdvertising( nearby_connections_->StopAdvertising(
base::BindOnce([](ConnectionsStatus status) { kServiceId, base::BindOnce([](ConnectionsStatus status) {
NS_LOG(VERBOSE) << __func__ NS_LOG(VERBOSE) << __func__
<< ": Stop advertising attempted over Nearby " << ": Stop advertising attempted over Nearby "
"Connections with result: " "Connections with result: "
...@@ -155,7 +155,7 @@ void NearbyConnectionsManagerImpl::StartDiscovery( ...@@ -155,7 +155,7 @@ void NearbyConnectionsManagerImpl::StartDiscovery(
void NearbyConnectionsManagerImpl::StopDiscovery() { void NearbyConnectionsManagerImpl::StopDiscovery() {
if (nearby_connections_) { if (nearby_connections_) {
nearby_connections_->StopDiscovery( nearby_connections_->StopDiscovery(
base::BindOnce([](ConnectionsStatus status) { kServiceId, base::BindOnce([](ConnectionsStatus status) {
NS_LOG(VERBOSE) << __func__ NS_LOG(VERBOSE) << __func__
<< ": Stop discovery attempted over Nearby " << ": Stop discovery attempted over Nearby "
"Connections with result: " "Connections with result: "
...@@ -203,7 +203,7 @@ void NearbyConnectionsManagerImpl::Connect( ...@@ -203,7 +203,7 @@ void NearbyConnectionsManagerImpl::Connect(
connect_timeout_timers_.emplace(endpoint_id, std::move(timeout_timer)); connect_timeout_timers_.emplace(endpoint_id, std::move(timeout_timer));
nearby_connections_->RequestConnection( nearby_connections_->RequestConnection(
endpoint_info, endpoint_id, kServiceId, endpoint_info, endpoint_id,
ConnectionOptions::New(std::move(allowed_mediums), ConnectionOptions::New(std::move(allowed_mediums),
std::move(bluetooth_mac_address)), std::move(bluetooth_mac_address)),
std::move(lifecycle_listener), std::move(lifecycle_listener),
...@@ -239,7 +239,7 @@ void NearbyConnectionsManagerImpl::Disconnect(const std::string& endpoint_id) { ...@@ -239,7 +239,7 @@ void NearbyConnectionsManagerImpl::Disconnect(const std::string& endpoint_id) {
return; return;
nearby_connections_->DisconnectFromEndpoint( nearby_connections_->DisconnectFromEndpoint(
endpoint_id, kServiceId, endpoint_id,
base::BindOnce( base::BindOnce(
[](const std::string& endpoint_id, ConnectionsStatus status) { [](const std::string& endpoint_id, ConnectionsStatus status) {
NS_LOG(VERBOSE) NS_LOG(VERBOSE)
...@@ -263,7 +263,7 @@ void NearbyConnectionsManagerImpl::Send(const std::string& endpoint_id, ...@@ -263,7 +263,7 @@ void NearbyConnectionsManagerImpl::Send(const std::string& endpoint_id,
RegisterPayloadStatusListener(payload->id, listener); RegisterPayloadStatusListener(payload->id, listener);
nearby_connections_->SendPayload( nearby_connections_->SendPayload(
{endpoint_id}, std::move(payload), kServiceId, {endpoint_id}, std::move(payload),
base::BindOnce( base::BindOnce(
[](const std::string& endpoint_id, ConnectionsStatus status) { [](const std::string& endpoint_id, ConnectionsStatus status) {
NS_LOG(VERBOSE) NS_LOG(VERBOSE)
...@@ -300,8 +300,8 @@ void NearbyConnectionsManagerImpl::OnFileCreated( ...@@ -300,8 +300,8 @@ void NearbyConnectionsManagerImpl::OnFileCreated(
ConnectionsCallback callback, ConnectionsCallback callback,
NearbyFileHandler::CreateFileResult result) { NearbyFileHandler::CreateFileResult result) {
nearby_connections_->RegisterPayloadFile( nearby_connections_->RegisterPayloadFile(
payload_id, std::move(result.input_file), std::move(result.output_file), kServiceId, payload_id, std::move(result.input_file),
std::move(callback)); std::move(result.output_file), std::move(callback));
} }
NearbyConnectionsManagerImpl::Payload* NearbyConnectionsManagerImpl::Payload*
...@@ -326,7 +326,7 @@ void NearbyConnectionsManagerImpl::Cancel(int64_t payload_id) { ...@@ -326,7 +326,7 @@ void NearbyConnectionsManagerImpl::Cancel(int64_t payload_id) {
payload_status_listeners_.erase(it); payload_status_listeners_.erase(it);
} }
nearby_connections_->CancelPayload( nearby_connections_->CancelPayload(
payload_id, kServiceId, payload_id,
base::BindOnce( base::BindOnce(
[](int64_t payload_id, ConnectionsStatus status) { [](int64_t payload_id, ConnectionsStatus status) {
NS_LOG(VERBOSE) NS_LOG(VERBOSE)
...@@ -367,7 +367,7 @@ void NearbyConnectionsManagerImpl::UpgradeBandwidth( ...@@ -367,7 +367,7 @@ void NearbyConnectionsManagerImpl::UpgradeBandwidth(
return; return;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_id, kServiceId, endpoint_id,
base::BindOnce( base::BindOnce(
[](const std::string& endpoint_id, ConnectionsStatus status) { [](const std::string& endpoint_id, ConnectionsStatus status) {
NS_LOG(VERBOSE) NS_LOG(VERBOSE)
...@@ -452,7 +452,7 @@ void NearbyConnectionsManagerImpl::OnConnectionInitiated( ...@@ -452,7 +452,7 @@ void NearbyConnectionsManagerImpl::OnConnectionInitiated(
payload_listener.InitWithNewPipeAndPassReceiver()); payload_listener.InitWithNewPipeAndPassReceiver());
nearby_connections_->AcceptConnection( nearby_connections_->AcceptConnection(
endpoint_id, std::move(payload_listener), kServiceId, endpoint_id, std::move(payload_listener),
base::BindOnce( base::BindOnce(
[](const std::string& endpoint_id, ConnectionsStatus status) { [](const std::string& endpoint_id, ConnectionsStatus status) {
NS_LOG(VERBOSE) NS_LOG(VERBOSE)
...@@ -572,7 +572,8 @@ void NearbyConnectionsManagerImpl::OnPayloadTransferUpdate( ...@@ -572,7 +572,8 @@ void NearbyConnectionsManagerImpl::OnPayloadTransferUpdate(
if (!payload_it->second->content->is_bytes()) { if (!payload_it->second->content->is_bytes()) {
NS_LOG(WARNING) << "Received unknown payload of file type. Cancelling."; NS_LOG(WARNING) << "Received unknown payload of file type. Cancelling.";
nearby_connections_->CancelPayload(payload_it->first, base::DoNothing()); nearby_connections_->CancelPayload(kServiceId, payload_it->first,
base::DoNothing());
return; return;
} }
...@@ -599,7 +600,7 @@ bool NearbyConnectionsManagerImpl::BindNearbyConnections() { ...@@ -599,7 +600,7 @@ bool NearbyConnectionsManagerImpl::BindNearbyConnections() {
void NearbyConnectionsManagerImpl::Reset() { void NearbyConnectionsManagerImpl::Reset() {
if (nearby_connections_) { if (nearby_connections_) {
nearby_connections_->StopAllEndpoints( nearby_connections_->StopAllEndpoints(
base::BindOnce([](ConnectionsStatus status) { kServiceId, base::BindOnce([](ConnectionsStatus status) {
NS_LOG(VERBOSE) << __func__ NS_LOG(VERBOSE) << __func__
<< ": Stop all endpoints attempted over Nearby " << ": Stop all endpoints attempted over Nearby "
"Connections with result: " "Connections with result: "
......
...@@ -26,12 +26,14 @@ ...@@ -26,12 +26,14 @@
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/shared_remote.h" #include "mojo/public/cpp/bindings/shared_remote.h"
#include "third_party/nearby/src/cpp/core/core.h" #include "third_party/nearby/src/cpp/core/internal/service_controller.h"
namespace location { namespace location {
namespace nearby { namespace nearby {
namespace connections { namespace connections {
class Core;
// Implementation of the NearbyConnections mojo interface. // Implementation of the NearbyConnections mojo interface.
// This class acts as a bridge to the NearbyConnections library which is pulled // This class acts as a bridge to the NearbyConnections library which is pulled
// in as a third_party dependency. It handles the translation from mojo calls to // in as a third_party dependency. It handles the translation from mojo calls to
...@@ -50,7 +52,7 @@ class NearbyConnections : public mojom::NearbyConnections { ...@@ -50,7 +52,7 @@ class NearbyConnections : public mojom::NearbyConnections {
mojom::NearbyConnectionsDependenciesPtr dependencies, mojom::NearbyConnectionsDependenciesPtr dependencies,
scoped_refptr<base::SequencedTaskRunner> io_task_runner, scoped_refptr<base::SequencedTaskRunner> io_task_runner,
base::OnceClosure on_disconnect, base::OnceClosure on_disconnect,
std::unique_ptr<Core> core = std::make_unique<Core>()); std::unique_ptr<ServiceController> service_controller = nullptr);
NearbyConnections(const NearbyConnections&) = delete; NearbyConnections(const NearbyConnections&) = delete;
NearbyConnections& operator=(const NearbyConnections&) = delete; NearbyConnections& operator=(const NearbyConnections&) = delete;
...@@ -85,41 +87,52 @@ class NearbyConnections : public mojom::NearbyConnections { ...@@ -85,41 +87,52 @@ class NearbyConnections : public mojom::NearbyConnections {
// mojom::NearbyConnections: // mojom::NearbyConnections:
void StartAdvertising( void StartAdvertising(
const std::vector<uint8_t>& endpoint_info,
const std::string& service_id, const std::string& service_id,
const std::vector<uint8_t>& endpoint_info,
mojom::AdvertisingOptionsPtr options, mojom::AdvertisingOptionsPtr options,
mojo::PendingRemote<mojom::ConnectionLifecycleListener> listener, mojo::PendingRemote<mojom::ConnectionLifecycleListener> listener,
StartAdvertisingCallback callback) override; StartAdvertisingCallback callback) override;
void StopAdvertising(StopAdvertisingCallback callback) override; void StopAdvertising(const std::string& service_id,
StopAdvertisingCallback callback) override;
void StartDiscovery( void StartDiscovery(
const std::string& service_id, const std::string& service_id,
mojom::DiscoveryOptionsPtr options, mojom::DiscoveryOptionsPtr options,
mojo::PendingRemote<mojom::EndpointDiscoveryListener> listener, mojo::PendingRemote<mojom::EndpointDiscoveryListener> listener,
StartDiscoveryCallback callback) override; StartDiscoveryCallback callback) override;
void StopDiscovery(StopDiscoveryCallback callback) override; void StopDiscovery(const std::string& service_id,
StopDiscoveryCallback callback) override;
void RequestConnection( void RequestConnection(
const std::string& service_id,
const std::vector<uint8_t>& endpoint_info, const std::vector<uint8_t>& endpoint_info,
const std::string& endpoint_id, const std::string& endpoint_id,
mojom::ConnectionOptionsPtr options, mojom::ConnectionOptionsPtr options,
mojo::PendingRemote<mojom::ConnectionLifecycleListener> listener, mojo::PendingRemote<mojom::ConnectionLifecycleListener> listener,
RequestConnectionCallback callback) override; RequestConnectionCallback callback) override;
void DisconnectFromEndpoint(const std::string& endpoint_id, void DisconnectFromEndpoint(const std::string& service_id,
const std::string& endpoint_id,
DisconnectFromEndpointCallback callback) override; DisconnectFromEndpointCallback callback) override;
void AcceptConnection(const std::string& endpoint_id, void AcceptConnection(const std::string& service_id,
const std::string& endpoint_id,
mojo::PendingRemote<mojom::PayloadListener> listener, mojo::PendingRemote<mojom::PayloadListener> listener,
AcceptConnectionCallback callback) override; AcceptConnectionCallback callback) override;
void RejectConnection(const std::string& endpoint_id, void RejectConnection(const std::string& service_id,
const std::string& endpoint_id,
RejectConnectionCallback callback) override; RejectConnectionCallback callback) override;
void SendPayload(const std::vector<std::string>& endpoint_ids, void SendPayload(const std::string& service_id,
const std::vector<std::string>& endpoint_ids,
mojom::PayloadPtr payload, mojom::PayloadPtr payload,
SendPayloadCallback callback) override; SendPayloadCallback callback) override;
void CancelPayload(int64_t payload_id, void CancelPayload(const std::string& service_id,
int64_t payload_id,
CancelPayloadCallback callback) override; CancelPayloadCallback callback) override;
void StopAllEndpoints(StopAllEndpointsCallback callback) override; void StopAllEndpoints(const std::string& service_id,
StopAllEndpointsCallback callback) override;
void InitiateBandwidthUpgrade( void InitiateBandwidthUpgrade(
const std::string& service_id,
const std::string& endpoint_id, const std::string& endpoint_id,
InitiateBandwidthUpgradeCallback callback) override; InitiateBandwidthUpgradeCallback callback) override;
void RegisterPayloadFile(int64_t payload_id, void RegisterPayloadFile(const std::string& service_id,
int64_t payload_id,
base::File input_file, base::File input_file,
base::File output_file, base::File output_file,
RegisterPayloadFileCallback callback) override; RegisterPayloadFileCallback callback) override;
...@@ -134,6 +147,9 @@ class NearbyConnections : public mojom::NearbyConnections { ...@@ -134,6 +147,9 @@ class NearbyConnections : public mojom::NearbyConnections {
scoped_refptr<base::SingleThreadTaskRunner> GetThreadTaskRunner(); scoped_refptr<base::SingleThreadTaskRunner> GetThreadTaskRunner();
private: private:
Core* GetCore(const std::string& service_id);
void InitializeOfflineServiceController();
void OnDisconnect(); void OnDisconnect();
mojo::Receiver<mojom::NearbyConnections> nearby_connections_; mojo::Receiver<mojom::NearbyConnections> nearby_connections_;
...@@ -148,9 +164,12 @@ class NearbyConnections : public mojom::NearbyConnections { ...@@ -148,9 +164,12 @@ class NearbyConnections : public mojom::NearbyConnections {
mojo::SharedRemote<sharing::mojom::WebRtcSignalingMessenger> mojo::SharedRemote<sharing::mojom::WebRtcSignalingMessenger>
webrtc_signaling_messenger_; webrtc_signaling_messenger_;
// Core is thread-safe as its operations are always dispatched to a std::unique_ptr<ServiceController> service_controller_;
// single-thread executor.
std::unique_ptr<Core> core_; // Map from service ID to the Core object to be used for that service. Each
// service uses its own Core object, but all Core objects share the underlying
// ServiceController instance.
base::flat_map<std::string, std::unique_ptr<Core>> service_id_to_core_map_;
// input_file_map_ is accessed from background threads. // input_file_map_ is accessed from background threads.
base::Lock input_file_lock_; base::Lock input_file_lock_;
......
...@@ -186,16 +186,15 @@ class NearbyConnectionsTest : public testing::Test { ...@@ -186,16 +186,15 @@ class NearbyConnectionsTest : public testing::Test {
auto dependencies = mojom::NearbyConnectionsDependencies::New( auto dependencies = mojom::NearbyConnectionsDependencies::New(
bluetooth_adapter_.adapter_.BindNewPipeAndPassRemote(), bluetooth_adapter_.adapter_.BindNewPipeAndPassRemote(),
std::move(webrtc_dependencies)); std::move(webrtc_dependencies));
service_controller_ = auto service_controller =
std::make_unique<testing::NiceMock<MockServiceController>>(); std::make_unique<testing::NiceMock<MockServiceController>>();
service_controller_ptr_ = service_controller_.get(); service_controller_ptr_ = service_controller.get();
nearby_connections_ = std::make_unique<NearbyConnections>( nearby_connections_ = std::make_unique<NearbyConnections>(
remote_.BindNewPipeAndPassReceiver(), std::move(dependencies), remote_.BindNewPipeAndPassReceiver(), std::move(dependencies),
/*io_task_runner=*/nullptr, /*io_task_runner=*/nullptr,
base::BindOnce(&NearbyConnectionsTest::OnDisconnect, base::BindOnce(&NearbyConnectionsTest::OnDisconnect,
base::Unretained(this)), base::Unretained(this)),
std::make_unique<Core>( std::move(service_controller));
[&]() { return service_controller_.release(); }));
} }
void OnDisconnect() { disconnect_run_loop_.Quit(); } void OnDisconnect() { disconnect_run_loop_.Quit(); }
...@@ -278,7 +277,7 @@ class NearbyConnectionsTest : public testing::Test { ...@@ -278,7 +277,7 @@ class NearbyConnectionsTest : public testing::Test {
base::RunLoop start_advertising_run_loop; base::RunLoop start_advertising_run_loop;
nearby_connections_->StartAdvertising( nearby_connections_->StartAdvertising(
endpoint_info, kServiceId, CreateAdvertisingOptions(), kServiceId, endpoint_info, CreateAdvertisingOptions(),
fake_connection_life_cycle_listener.receiver.BindNewPipeAndPassRemote(), fake_connection_life_cycle_listener.receiver.BindNewPipeAndPassRemote(),
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
...@@ -328,7 +327,7 @@ class NearbyConnectionsTest : public testing::Test { ...@@ -328,7 +327,7 @@ class NearbyConnectionsTest : public testing::Test {
base::RunLoop request_connection_run_loop; base::RunLoop request_connection_run_loop;
nearby_connections_->RequestConnection( nearby_connections_->RequestConnection(
endpoint_info, endpoint_data.remote_endpoint_id, kServiceId, endpoint_info, endpoint_data.remote_endpoint_id,
CreateConnectionOptions(bluetooth_mac_address), CreateConnectionOptions(bluetooth_mac_address),
fake_connection_life_cycle_listener.receiver.BindNewPipeAndPassRemote(), fake_connection_life_cycle_listener.receiver.BindNewPipeAndPassRemote(),
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
...@@ -356,7 +355,7 @@ class NearbyConnectionsTest : public testing::Test { ...@@ -356,7 +355,7 @@ class NearbyConnectionsTest : public testing::Test {
base::RunLoop accept_connection_run_loop; base::RunLoop accept_connection_run_loop;
nearby_connections_->AcceptConnection( nearby_connections_->AcceptConnection(
remote_endpoint_id, kServiceId, remote_endpoint_id,
fake_payload_listener.receiver.BindNewPipeAndPassRemote(), fake_payload_listener.receiver.BindNewPipeAndPassRemote(),
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
...@@ -375,9 +374,6 @@ class NearbyConnectionsTest : public testing::Test { ...@@ -375,9 +374,6 @@ class NearbyConnectionsTest : public testing::Test {
std::unique_ptr<NearbyConnections> nearby_connections_; std::unique_ptr<NearbyConnections> nearby_connections_;
testing::NiceMock<MockServiceController>* service_controller_ptr_; testing::NiceMock<MockServiceController>* service_controller_ptr_;
base::RunLoop disconnect_run_loop_; base::RunLoop disconnect_run_loop_;
private:
std::unique_ptr<testing::NiceMock<MockServiceController>> service_controller_;
}; };
TEST_F(NearbyConnectionsTest, RemoteDisconnect) { TEST_F(NearbyConnectionsTest, RemoteDisconnect) {
...@@ -449,7 +445,7 @@ TEST_F(NearbyConnectionsTest, StopDiscovery) { ...@@ -449,7 +445,7 @@ TEST_F(NearbyConnectionsTest, StopDiscovery) {
base::RunLoop stop_discovery_run_loop; base::RunLoop stop_discovery_run_loop;
nearby_connections_->StopDiscovery( nearby_connections_->StopDiscovery(
base::BindLambdaForTesting([&](mojom::Status status) { kServiceId, base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
stop_discovery_run_loop.Quit(); stop_discovery_run_loop.Quit();
})); }));
...@@ -588,7 +584,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) { ...@@ -588,7 +584,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) {
}); });
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
bandwidth_upgrade_run_loop.Quit(); bandwidth_upgrade_run_loop.Quit();
...@@ -657,7 +653,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionDisconnect) { ...@@ -657,7 +653,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionDisconnect) {
base::RunLoop disconnect_from_endpoint_run_loop; base::RunLoop disconnect_from_endpoint_run_loop;
nearby_connections_->DisconnectFromEndpoint( nearby_connections_->DisconnectFromEndpoint(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
disconnect_from_endpoint_run_loop.Quit(); disconnect_from_endpoint_run_loop.Quit();
...@@ -725,7 +721,7 @@ TEST_F(NearbyConnectionsTest, SendBytesPayload) { ...@@ -725,7 +721,7 @@ TEST_F(NearbyConnectionsTest, SendBytesPayload) {
base::RunLoop send_payload_run_loop; base::RunLoop send_payload_run_loop;
nearby_connections_->SendPayload( nearby_connections_->SendPayload(
{endpoint_data.remote_endpoint_id}, kServiceId, {endpoint_data.remote_endpoint_id},
mojom::Payload::New(kPayloadId, mojom::Payload::New(kPayloadId,
mojom::PayloadContent::NewBytes( mojom::PayloadContent::NewBytes(
mojom::BytesPayload::New(expected_payload))), mojom::BytesPayload::New(expected_payload))),
...@@ -769,7 +765,7 @@ TEST_F(NearbyConnectionsTest, SendBytesPayloadCancelled) { ...@@ -769,7 +765,7 @@ TEST_F(NearbyConnectionsTest, SendBytesPayloadCancelled) {
base::RunLoop send_payload_run_loop; base::RunLoop send_payload_run_loop;
nearby_connections_->SendPayload( nearby_connections_->SendPayload(
{endpoint_data.remote_endpoint_id}, kServiceId, {endpoint_data.remote_endpoint_id},
mojom::Payload::New(kPayloadId, mojom::Payload::New(kPayloadId,
mojom::PayloadContent::NewBytes( mojom::PayloadContent::NewBytes(
mojom::BytesPayload::New(expected_payload))), mojom::BytesPayload::New(expected_payload))),
...@@ -785,7 +781,8 @@ TEST_F(NearbyConnectionsTest, SendBytesPayloadCancelled) { ...@@ -785,7 +781,8 @@ TEST_F(NearbyConnectionsTest, SendBytesPayloadCancelled) {
base::RunLoop cancel_payload_run_loop; base::RunLoop cancel_payload_run_loop;
nearby_connections_->CancelPayload( nearby_connections_->CancelPayload(
kPayloadId, base::BindLambdaForTesting([&](mojom::Status status) { kServiceId, kPayloadId,
base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
cancel_payload_run_loop.Quit(); cancel_payload_run_loop.Quit();
})); }));
...@@ -840,7 +837,7 @@ TEST_F(NearbyConnectionsTest, SendFilePayload) { ...@@ -840,7 +837,7 @@ TEST_F(NearbyConnectionsTest, SendFilePayload) {
base::RunLoop send_payload_run_loop; base::RunLoop send_payload_run_loop;
nearby_connections_->SendPayload( nearby_connections_->SendPayload(
{endpoint_data.remote_endpoint_id}, kServiceId, {endpoint_data.remote_endpoint_id},
mojom::Payload::New(kPayloadId, mojom::Payload::New(kPayloadId,
mojom::PayloadContent::NewFile( mojom::PayloadContent::NewFile(
mojom::FilePayload::New(std::move(input_file)))), mojom::FilePayload::New(std::move(input_file)))),
...@@ -928,7 +925,7 @@ TEST_F(NearbyConnectionsTest, StopAdvertising) { ...@@ -928,7 +925,7 @@ TEST_F(NearbyConnectionsTest, StopAdvertising) {
base::RunLoop stop_advertising_run_loop; base::RunLoop stop_advertising_run_loop;
nearby_connections_->StopAdvertising( nearby_connections_->StopAdvertising(
base::BindLambdaForTesting([&](mojom::Status status) { kServiceId, base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
stop_advertising_run_loop.Quit(); stop_advertising_run_loop.Quit();
})); }));
...@@ -983,7 +980,7 @@ TEST_F(NearbyConnectionsTest, DisconnectAllEndpoints) { ...@@ -983,7 +980,7 @@ TEST_F(NearbyConnectionsTest, DisconnectAllEndpoints) {
base::RunLoop stop_endpoints_run_loop; base::RunLoop stop_endpoints_run_loop;
nearby_connections_->StopAllEndpoints( nearby_connections_->StopAllEndpoints(
base::BindLambdaForTesting([&](mojom::Status status) { kServiceId, base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
stop_endpoints_run_loop.Quit(); stop_endpoints_run_loop.Quit();
})); }));
...@@ -1000,7 +997,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeFails) { ...@@ -1000,7 +997,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeFails) {
EndpointData endpoint_data = CreateEndpointData(1); EndpointData endpoint_data = CreateEndpointData(1);
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status); EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status);
bandwidth_upgrade_run_loop.Quit(); bandwidth_upgrade_run_loop.Quit();
...@@ -1020,7 +1017,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterDiscoveringFails) { ...@@ -1020,7 +1017,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterDiscoveringFails) {
// Requesting a bandwidth upgrade should fail. // Requesting a bandwidth upgrade should fail.
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status); EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status);
bandwidth_upgrade_run_loop.Quit(); bandwidth_upgrade_run_loop.Quit();
...@@ -1037,7 +1034,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterAdvertisingFails) { ...@@ -1037,7 +1034,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterAdvertisingFails) {
// Requesting a bandwidth upgrade should fail. // Requesting a bandwidth upgrade should fail.
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status); EXPECT_EQ(mojom::Status::kOutOfOrderApiCall, status);
bandwidth_upgrade_run_loop.Quit(); bandwidth_upgrade_run_loop.Quit();
...@@ -1066,7 +1063,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterConnectionSucceeds) { ...@@ -1066,7 +1063,7 @@ TEST_F(NearbyConnectionsTest, InitiateBandwidthUpgradeAfterConnectionSucceeds) {
// Requesting a bandwidth upgrade should succeed. // Requesting a bandwidth upgrade should succeed.
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
nearby_connections_->InitiateBandwidthUpgrade( nearby_connections_->InitiateBandwidthUpgrade(
endpoint_data.remote_endpoint_id, kServiceId, endpoint_data.remote_endpoint_id,
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
bandwidth_upgrade_run_loop.Quit(); bandwidth_upgrade_run_loop.Quit();
...@@ -1139,7 +1136,7 @@ TEST_F(NearbyConnectionsTest, ReceiveFilePayload) { ...@@ -1139,7 +1136,7 @@ TEST_F(NearbyConnectionsTest, ReceiveFilePayload) {
base::RunLoop register_payload_run_loop; base::RunLoop register_payload_run_loop;
nearby_connections_->RegisterPayloadFile( nearby_connections_->RegisterPayloadFile(
kPayloadId, std::move(input_file), std::move(output_file), kServiceId, kPayloadId, std::move(input_file), std::move(output_file),
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kSuccess, status); EXPECT_EQ(mojom::Status::kSuccess, status);
register_payload_run_loop.Quit(); register_payload_run_loop.Quit();
...@@ -1217,7 +1214,7 @@ TEST_F(NearbyConnectionsTest, ReceiveFilePayloadNotRegistered) { ...@@ -1217,7 +1214,7 @@ TEST_F(NearbyConnectionsTest, ReceiveFilePayloadNotRegistered) {
TEST_F(NearbyConnectionsTest, RegisterPayloadFileInvalid) { TEST_F(NearbyConnectionsTest, RegisterPayloadFileInvalid) {
base::RunLoop register_payload_run_loop; base::RunLoop register_payload_run_loop;
nearby_connections_->RegisterPayloadFile( nearby_connections_->RegisterPayloadFile(
kPayloadId, base::File(), base::File(), kServiceId, kPayloadId, base::File(), base::File(),
base::BindLambdaForTesting([&](mojom::Status status) { base::BindLambdaForTesting([&](mojom::Status status) {
EXPECT_EQ(mojom::Status::kError, status); EXPECT_EQ(mojom::Status::kError, status);
register_payload_run_loop.Quit(); register_payload_run_loop.Quit();
......
...@@ -44,13 +44,16 @@ class MockNearbyConnections : public NearbyConnectionsMojom { ...@@ -44,13 +44,16 @@ class MockNearbyConnections : public NearbyConnectionsMojom {
MOCK_METHOD(void, MOCK_METHOD(void,
StartAdvertising, StartAdvertising,
(const std::vector<uint8_t>& endpoint_info, (const std::string& service_id,
const std::string& service_id, const std::vector<uint8_t>& endpoint_info,
AdvertisingOptionsPtr, AdvertisingOptionsPtr,
mojo::PendingRemote<ConnectionLifecycleListener>, mojo::PendingRemote<ConnectionLifecycleListener>,
StartDiscoveryCallback), StartDiscoveryCallback),
(override)); (override));
MOCK_METHOD(void, StopAdvertising, (StopAdvertisingCallback), (override)); MOCK_METHOD(void,
StopAdvertising,
(const std::string& service_id, StopAdvertisingCallback),
(override));
MOCK_METHOD(void, MOCK_METHOD(void,
StartDiscovery, StartDiscovery,
(const std::string& service_id, (const std::string& service_id,
...@@ -58,10 +61,14 @@ class MockNearbyConnections : public NearbyConnectionsMojom { ...@@ -58,10 +61,14 @@ class MockNearbyConnections : public NearbyConnectionsMojom {
mojo::PendingRemote<EndpointDiscoveryListener>, mojo::PendingRemote<EndpointDiscoveryListener>,
StartDiscoveryCallback), StartDiscoveryCallback),
(override)); (override));
MOCK_METHOD(void, StopDiscovery, (StopDiscoveryCallback), (override)); MOCK_METHOD(void,
StopDiscovery,
(const std::string& service_id, StopDiscoveryCallback),
(override));
MOCK_METHOD(void, MOCK_METHOD(void,
RequestConnection, RequestConnection,
(const std::vector<uint8_t>& endpoint_info, (const std::string& service_id,
const std::vector<uint8_t>& endpoint_info,
const std::string& endpoint_id, const std::string& endpoint_id,
ConnectionOptionsPtr options, ConnectionOptionsPtr options,
mojo::PendingRemote<ConnectionLifecycleListener>, mojo::PendingRemote<ConnectionLifecycleListener>,
...@@ -69,41 +76,51 @@ class MockNearbyConnections : public NearbyConnectionsMojom { ...@@ -69,41 +76,51 @@ class MockNearbyConnections : public NearbyConnectionsMojom {
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
DisconnectFromEndpoint, DisconnectFromEndpoint,
(const std::string& endpoint_id, DisconnectFromEndpointCallback), (const std::string& service_id,
const std::string& endpoint_id,
DisconnectFromEndpointCallback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
AcceptConnection, AcceptConnection,
(const std::string& endpoint_id, (const std::string& service_id,
const std::string& endpoint_id,
mojo::PendingRemote<PayloadListener> listener, mojo::PendingRemote<PayloadListener> listener,
AcceptConnectionCallback callback), AcceptConnectionCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
RejectConnection, RejectConnection,
(const std::string& endpoint_id, (const std::string& service_id,
const std::string& endpoint_id,
RejectConnectionCallback callback), RejectConnectionCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
SendPayload, SendPayload,
(const std::vector<std::string>& endpoint_ids, (const std::string& service_id,
const std::vector<std::string>& endpoint_ids,
PayloadPtr payload, PayloadPtr payload,
SendPayloadCallback callback), SendPayloadCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
CancelPayload, CancelPayload,
(int64_t payload_id, CancelPayloadCallback callback), (const std::string& service_id,
int64_t payload_id,
CancelPayloadCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
StopAllEndpoints, StopAllEndpoints,
(DisconnectFromEndpointCallback callback), (const std::string& service_id,
DisconnectFromEndpointCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
InitiateBandwidthUpgrade, InitiateBandwidthUpgrade,
(const std::string& endpoint_id, (const std::string& service_id,
const std::string& endpoint_id,
InitiateBandwidthUpgradeCallback callback), InitiateBandwidthUpgradeCallback callback),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
RegisterPayloadFile, RegisterPayloadFile,
(int64_t payload_id, (const std::string& service_id,
int64_t payload_id,
base::File input_file, base::File input_file,
base::File output_file, base::File output_file,
RegisterPayloadFileCallback callback), RegisterPayloadFileCallback callback),
......
...@@ -127,13 +127,13 @@ interface NearbyConnections { ...@@ -127,13 +127,13 @@ interface NearbyConnections {
// advertisement can be active at a time and calling StartAdvertising() while // advertisement can be active at a time and calling StartAdvertising() while
// advertising will fail and return Status::kAlreadyAdvertising. // advertising will fail and return Status::kAlreadyAdvertising.
// //
// endpoint_info - The local info to be broadcasted. May contain a human
// readable name to appear on other devices if broadcasting
// in high visibility mode.
// service_id - An identifier to advertise your app to other endpoints. // service_id - An identifier to advertise your app to other endpoints.
// This can be an arbitrary string, so long as it uniquely // This can be an arbitrary string, so long as it uniquely
// identifies your service. A good default is to use your // identifies your service. A good default is to use your
// app's package name. // app's package name.
// endpoint_info - The local info to be broadcasted. May contain a human
// readable name to appear on other devices if broadcasting
// in high visibility mode.
// options - The options for advertising. // options - The options for advertising.
// listener - An interface notified when remote endpoints request a // listener - An interface notified when remote endpoints request a
// connection to this endpoint. // connection to this endpoint.
...@@ -142,7 +142,7 @@ interface NearbyConnections { ...@@ -142,7 +142,7 @@ interface NearbyConnections {
// Status::kAlreadyAdvertising if the app is already advertising. // Status::kAlreadyAdvertising if the app is already advertising.
// Status::kOutOfOrderApiCall if the app is currently connected to remote // Status::kOutOfOrderApiCall if the app is currently connected to remote
// endpoints; call StopAllEndpoints first. // endpoints; call StopAllEndpoints first.
StartAdvertising(array<uint8> endpoint_info, string service_id, StartAdvertising(string service_id, array<uint8> endpoint_info,
AdvertisingOptions options, AdvertisingOptions options,
pending_remote<ConnectionLifecycleListener> listener) pending_remote<ConnectionLifecycleListener> listener)
=> (Status status); => (Status status);
...@@ -152,9 +152,11 @@ interface NearbyConnections { ...@@ -152,9 +152,11 @@ interface NearbyConnections {
// itself or goes inactive. Payloads can still be sent to connected // itself or goes inactive. Payloads can still be sent to connected
// endpoints after advertising ends. // endpoints after advertising ends.
// //
// service_id - Identifier used in the preceding StartAdvertising() call.
//
// Possible return values include: // Possible return values include:
// Status::kSuccess returned after advertising got stopped. // Status::kSuccess returned after advertising got stopped.
StopAdvertising() => (Status status); StopAdvertising(string service_id) => (Status status);
// Starts discovery for remote endpoints with the specified service ID. // Starts discovery for remote endpoints with the specified service ID.
// //
...@@ -177,12 +179,15 @@ interface NearbyConnections { ...@@ -177,12 +179,15 @@ interface NearbyConnections {
// goes inactive. Payloads can still be sent to connected endpoints after // goes inactive. Payloads can still be sent to connected endpoints after
// discovery ends. // discovery ends.
// //
// service_id - Identifier used in the preceding StartDiscovery() call.
//
// Possible return values include: // Possible return values include:
// Status::kSuccess returned after discovery got stopped. // Status::kSuccess returned after discovery got stopped.
StopDiscovery() => (Status status); StopDiscovery(string service_id) => (Status status);
// Sends a request to connect to a remote endpoint. // Sends a request to connect to a remote endpoint.
// //
// service_id - Service ID used to discover the endpoint.
// endpoint_info - The local info including a human readable name to appear on // endpoint_info - The local info including a human readable name to appear on
// the remote endpoint. // the remote endpoint.
// endpoint_id - The identifier for the remote endpoint to which a // endpoint_id - The identifier for the remote endpoint to which a
...@@ -201,7 +206,9 @@ interface NearbyConnections { ...@@ -201,7 +206,9 @@ interface NearbyConnections {
// Status::kWifiLanError if we failed to connect because of an // Status::kWifiLanError if we failed to connect because of an
// issue with WiFi. // issue with WiFi.
// Status::kError if we failed to connect for any other reason. // Status::kError if we failed to connect for any other reason.
RequestConnection(array<uint8> endpoint_info, string endpoint_id, RequestConnection(string service_id,
array<uint8> endpoint_info,
string endpoint_id,
ConnectionOptions options, ConnectionOptions options,
pending_remote<ConnectionLifecycleListener> listener) pending_remote<ConnectionLifecycleListener> listener)
=> (Status status); => (Status status);
...@@ -209,6 +216,7 @@ interface NearbyConnections { ...@@ -209,6 +216,7 @@ interface NearbyConnections {
// Accepts a connection to a remote endpoint. This method must be called // Accepts a connection to a remote endpoint. This method must be called
// before Payloads can be exchanged with the remote endpoint. // before Payloads can be exchanged with the remote endpoint.
// //
// service_id - Service ID used to bootstrap the connection.
// endpoint_id - The identifier for the remote endpoint. Should match the // endpoint_id - The identifier for the remote endpoint. Should match the
// value provided in a call to // value provided in a call to
// ConnectionsLifecycleListener::OnConnectionInitiated(). // ConnectionsLifecycleListener::OnConnectionInitiated().
...@@ -220,11 +228,14 @@ interface NearbyConnections { ...@@ -220,11 +228,14 @@ interface NearbyConnections {
// Status::kOutOfOrderApiCall if // Status::kOutOfOrderApiCall if
// ConnectionsLifecycleListener::OnConnectionInitiated() has not been // ConnectionsLifecycleListener::OnConnectionInitiated() has not been
// called for the |endpoint_id|. // called for the |endpoint_id|.
AcceptConnection(string endpoint_id, pending_remote<PayloadListener> listener) AcceptConnection(string service_id,
string endpoint_id,
pending_remote<PayloadListener> listener)
=> (Status status); => (Status status);
// Rejects a connection to a remote endpoint. // Rejects a connection to a remote endpoint.
// //
// service_id - Service ID used to bootstrap the connection.
// endpoint_id - The identifier for the remote endpoint. Should match the // endpoint_id - The identifier for the remote endpoint. Should match the
// value provided in a call to // value provided in a call to
// ConnectionsLifecycleListener::OnConnectionInitiated(). // ConnectionsLifecycleListener::OnConnectionInitiated().
...@@ -235,20 +246,23 @@ interface NearbyConnections { ...@@ -235,20 +246,23 @@ interface NearbyConnections {
// Status::kOutOfOrderApiCall if // Status::kOutOfOrderApiCall if
// ConnectionsLifecycleListener::OnConnectionInitiated() has not been // ConnectionsLifecycleListener::OnConnectionInitiated() has not been
// called for the |endpoint_id|. // called for the |endpoint_id|.
RejectConnection(string endpoint_id) => (Status status); RejectConnection(string service_id, string endpoint_id) => (Status status);
// Disconnects from a remote endpoint. Payloads can no longer be sent // Disconnects from a remote endpoint. Payloads can no longer be sent
// to or received from the endpoint after this method is called. // to or received from the endpoint after this method is called.
// //
// service_id - Service ID used to bootstrap the connection.
// endpoint_id - The identifier for the remote endpoint to disconnect from. // endpoint_id - The identifier for the remote endpoint to disconnect from.
// Possible return values include: // Possible return values include:
// Status::kSuccess disconnected successfully. // Status::kSuccess disconnected successfully.
DisconnectFromEndpoint(string endpoint_id) => (Status status); DisconnectFromEndpoint(string service_id,
string endpoint_id) => (Status status);
// Sends a Payload to a list of remote endpoints. Payloads can only be sent to // Sends a Payload to a list of remote endpoints. Payloads can only be sent to
// remote endpoints once a notice of connection acceptance has been delivered // remote endpoints once a notice of connection acceptance has been delivered
// via ConnectionsLifecycleListener::OnConnectionResult(). // via ConnectionsLifecycleListener::OnConnectionResult().
// //
// service_id - Service ID used to bootstrap the connection.
// endpoint_ids - Array of remote endpoint identifiers for to which the // endpoint_ids - Array of remote endpoint identifiers for to which the
// payload should be sent. // payload should be sent.
// payload - The Payload to be sent. // payload - The Payload to be sent.
...@@ -263,14 +277,18 @@ interface NearbyConnections { ...@@ -263,14 +277,18 @@ interface NearbyConnections {
// still occur during transmission (and at different times for different // still occur during transmission (and at different times for different
// endpoints), and will be delivered via // endpoints), and will be delivered via
// PayloadListener::OnPayloadTransferUpdate(). // PayloadListener::OnPayloadTransferUpdate().
SendPayload(array<string> endpoint_ids, Payload payload) => (Status status); SendPayload(string service_id,
array<string> endpoint_ids,
Payload payload) => (Status status);
// Cancels a Payload currently in-flight to or from remote endpoint(s). // Cancels a Payload currently in-flight to or from remote endpoint(s).
// //
// service_id - Service ID used to bootstrap the connection.
//
// payload_id - The identifier for the Payload to be cancelled. // payload_id - The identifier for the Payload to be cancelled.
// Possible return values include: // Possible return values include:
// Status::kSuccess if the payload got cancelled. // Status::kSuccess if the payload got cancelled.
CancelPayload(int64 payload_id) => (Status status); CancelPayload(string service_id, int64 payload_id) => (Status status);
// Disconnects from, and removes all traces of, all connected and/or // Disconnects from, and removes all traces of, all connected and/or
// discovered endpoints. As a side effect of this call, both // discovered endpoints. As a side effect of this call, both
...@@ -278,28 +296,37 @@ interface NearbyConnections { ...@@ -278,28 +296,37 @@ interface NearbyConnections {
// StopAllEndpoints, no further operations with remote endpoints will // StopAllEndpoints, no further operations with remote endpoints will
// be possible until a new call to one of StartAdvertising or // be possible until a new call to one of StartAdvertising or
// StartDiscovery. // StartDiscovery.
//
// service_id - Service ID used to discover endpoints.
//
// Possible return values include: // Possible return values include:
// Status::kSuccess disconnected from all endpoints successfully. // Status::kSuccess disconnected from all endpoints successfully.
StopAllEndpoints() => (Status status); StopAllEndpoints(string service_id) => (Status status);
// Sends a request to initiate connection bandwidth upgrade. // Sends a request to initiate connection bandwidth upgrade.
// //
// service_id - Service ID used to discover the endpoint.
// endpoint_id - The identifier for the remote endpoint which will be // endpoint_id - The identifier for the remote endpoint which will be
// switching to a higher connection data rate and possibly // switching to a higher connection data rate and possibly
// different wireless protocol. On success, calls // different wireless protocol. On success, calls
// ConnectionLifecycleListener::OnBandwidthChanged. // ConnectionLifecycleListener::OnBandwidthChanged.
// Possible return values include: // Possible return values include:
// Status::kSuccess if upgraded successfully. // Status::kSuccess if upgraded successfully.
InitiateBandwidthUpgrade(string endpoint_id) => (Status status); InitiateBandwidthUpgrade(string service_id,
string endpoint_id) => (Status status);
// Register a pair of input and output file for handling incoming file // Register a pair of input and output file for handling incoming file
// payload associated with |payload_id_|, which is determined by feature // payload associated with |payload_id_|, which is determined by feature
// specific design. The |input_file| should be opened for read access, and // specific design. The |input_file| should be opened for read access, and
// |output_file| should be opened for write access. // |output_file| should be opened for write access.
//
// service_id - Service ID used to discover the endpoint.
//
// Possible return values include: // Possible return values include:
// Status::kSuccess if file is registered successfully. // Status::kSuccess if file is registered successfully.
// Status::kError if file is not opened correctly. // Status::kError if file is not opened correctly.
RegisterPayloadFile(int64 payload_id, RegisterPayloadFile(string service_id,
int64 payload_id,
mojo_base.mojom.ReadOnlyFile input_file, mojo_base.mojom.ReadOnlyFile input_file,
mojo_base.mojom.File output_file) mojo_base.mojom.File output_file)
=> (Status status); => (Status status);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment