blob: 0696e4fc8834cf6e9ff5365ac34256cf900544ad [file] [log] [blame]
Ryan Keanefdebe6c2019-09-06 14:12:51 -07001// Copyright 2019 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#include "platform/api/tls_connection.h"
6
7#include "platform/api/task_runner.h"
8
9namespace openscreen {
10namespace platform {
11
12void TlsConnection::OnWriteBlocked() {
13 if (!client_) {
14 return;
15 }
16
17 task_runner_->PostTask([this]() {
18 // TODO(issues/71): |this| may be invalid at this point.
19 this->client_->OnWriteBlocked(this);
20 });
21}
22
23void TlsConnection::OnWriteUnblocked() {
24 if (!client_) {
25 return;
26 }
27
28 task_runner_->PostTask([this]() {
29 // TODO(issues/71): |this| may be invalid at this point.
30 this->client_->OnWriteUnblocked(this);
31 });
32}
33
34void TlsConnection::OnError(Error error) {
35 if (!client_) {
36 return;
37 }
38
39 task_runner_->PostTask([e = std::move(error), this]() mutable {
40 // TODO(issues/71): |this| may be invalid at this point.
41 this->client_->OnError(this, std::move(e));
42 });
43}
44
45void TlsConnection::OnRead(std::vector<uint8_t> message) {
46 if (!client_) {
47 return;
48 }
49
50 task_runner_->PostTask([m = std::move(message), this]() mutable {
51 // TODO(issues/71): |this| may be invalid at this point.
52 this->client_->OnRead(this, std::move(m));
53 });
54}
55
56} // namespace platform
57} // namespace openscreen