forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
note_taking_controller.cc
46 lines (35 loc) · 1.14 KB
/
note_taking_controller.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2017 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 "ash/note_taking_controller.h"
#include "base/bind.h"
namespace ash {
NoteTakingController::NoteTakingController() : binding_(this) {}
NoteTakingController::~NoteTakingController() = default;
void NoteTakingController::BindRequest(
mojom::NoteTakingControllerRequest request) {
binding_.Bind(std::move(request));
}
void NoteTakingController::SetClient(
mojom::NoteTakingControllerClientPtr client) {
DCHECK(!client_);
client_ = std::move(client);
client_.set_connection_error_handler(base::Bind(
&NoteTakingController::OnClientConnectionLost, base::Unretained(this)));
}
bool NoteTakingController::CanCreateNote() const {
return static_cast<bool>(client_);
}
void NoteTakingController::CreateNote() {
DCHECK(client_);
client_->CreateNote();
}
void NoteTakingController::OnClientConnectionLost() {
client_.reset();
binding_.Close();
}
void NoteTakingController::FlushMojoForTesting() {
if (client_)
client_.FlushForTesting();
}
} // namespace ash