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

[CrOS MultiDevice] Add //chromeos/services/secure_channel w/ Mojo files.

This CL creates a new directory in //chromeos/services for the upcoming
SecureChannel service (see go/chrome-os-multi-device-apis).

Additionally, this CL adds the secure_channel.mojom file which will be
used to implement the service. Currently, that file only defines the
ConnectionDelegate interface, which is intended to be implemented by
clients of the service. This CL adds a test double for that class, to be
used in a follow-up CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1038649

Bug: 824568, 752273
Change-Id: I9ce9d7d7bff02464e1eec71d3193c63602e27477
Reviewed-on: https://chromium-review.googlesource.com/1033509Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555276}
parent 556cf9a4
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
static_library("test_support") {
testonly = true
sources = [
"fake_connection_delegate.cc",
"fake_connection_delegate.h",
]
deps = [
"//base",
"//chromeos/services/secure_channel/public/mojom",
]
}
include_rules = [
"+mojo/public/cpp",
]
khorimoto@chromium.org
jlklein@chromium.org
# COMPONENT: UI>ProximityAuth
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/secure_channel/fake_connection_delegate.h"
namespace chromeos {
namespace secure_channel {
FakeConnectionDelegate::FakeConnectionDelegate() = default;
FakeConnectionDelegate::~FakeConnectionDelegate() = default;
mojom::ConnectionDelegatePtr FakeConnectionDelegate::GenerateInterfacePtr() {
mojom::ConnectionDelegatePtr interface_ptr;
bindings_.AddBinding(this, mojo::MakeRequest(&interface_ptr));
return interface_ptr;
}
void FakeConnectionDelegate::DisconnectGeneratedPtrs() {
bindings_.CloseAllBindings();
}
void FakeConnectionDelegate::OnConnectionAttemptFailure(
mojom::ConnectionAttemptFailureReason reason) {
connection_attempt_failure_reason_ = reason;
}
} // namespace secure_channel
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_CONNECTION_DELEGATE_H_
#define CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_CONNECTION_DELEGATE_H_
#include "base/macros.h"
#include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace chromeos {
namespace secure_channel {
// Test ConnectionDelegate implementation.
class FakeConnectionDelegate : public mojom::ConnectionDelegate {
public:
FakeConnectionDelegate();
~FakeConnectionDelegate() override;
mojom::ConnectionDelegatePtr GenerateInterfacePtr();
void DisconnectGeneratedPtrs();
const base::Optional<mojom::ConnectionAttemptFailureReason>&
connection_attempt_failure_reason() const {
return connection_attempt_failure_reason_;
}
private:
// mojom::ConnectionDelegate:
void OnConnectionAttemptFailure(
mojom::ConnectionAttemptFailureReason reason) override;
mojo::BindingSet<mojom::ConnectionDelegate> bindings_;
base::Optional<mojom::ConnectionAttemptFailureReason>
connection_attempt_failure_reason_;
DISALLOW_COPY_AND_ASSIGN(FakeConnectionDelegate);
};
} // namespace secure_channel
} // namespace chromeos
#endif // CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_CONNECTION_DELEGATE_H_
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [
"secure_channel.mojom",
]
public_deps = [
"//mojo/public/mojom/base",
]
}
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chromeos.secure_channel.mojom;
enum ConnectionAttemptFailureReason {
AUTHENTICATION_ERROR,
GATT_CONNECTION_ERROR,
REMOTE_DEVICE_INVALID_PUBLIC_KEY,
REMOTE_DEVICE_INVALID_BEACON_SEEDS,
REMOTE_DEVICE_INVALID_PSK,
TIMEOUT_FINDING_DEVICE
};
// Delegate interface used to handle connection attempt successes/failures. Note
// that this interface is intended to be implemented by clients of the
// DeviceSync service.
interface ConnectionDelegate {
// Invoked when a connection attempt failed (i.e., the failure occurred before
// a connection could be established).
OnConnectionAttemptFailure(ConnectionAttemptFailureReason reason);
// TODO(khorimoto): Add a callback to handle when a connection has completed
// successfully.
};
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