Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: components/arc/arc_bridge_service.cc

Issue 1495723004: Minimum implementation of ARC clipboard Bridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tryboy warnings Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/arc/arc_bridge_service.cc
diff --git a/components/arc/arc_bridge_service.cc b/components/arc/arc_bridge_service.cc
index 2d10d8a468d1e9ed5c41ae273a15c436f1e980ce..37c6d70d76fa88723f23f5c88a171536f76f3d21 100644
--- a/components/arc/arc_bridge_service.cc
+++ b/components/arc/arc_bridge_service.cc
@@ -80,6 +80,31 @@ void ArcBridgeService::CloseAppChannel() {
FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceClosed());
}
+void ArcBridgeService::OnClipboardInstanceReady(
+ ClipboardInstancePtr clipboard_ptr) {
+ DCHECK(CalledOnValidThread());
+ temporary_clipboard_ptr_ = std::move(clipboard_ptr);
+ temporary_clipboard_ptr_.QueryVersion(base::Bind(
+ &ArcBridgeService::OnClipboardVersionReady, weak_factory_.GetWeakPtr()));
+}
+
+void ArcBridgeService::OnClipboardVersionReady(int32_t version) {
+ DCHECK(CalledOnValidThread());
+ clipboard_ptr_ = std::move(temporary_clipboard_ptr_);
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceReady());
+ clipboard_ptr_.set_connection_error_handler(base::Bind(
+ &ArcBridgeService::CloseClipboardChannel, weak_factory_.GetWeakPtr()));
+}
+
+void ArcBridgeService::CloseClipboardChannel() {
+ DCHECK(CalledOnValidThread());
+ if (!clipboard_ptr_)
+ return;
+
+ clipboard_ptr_.reset();
+ FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceClosed());
+}
+
void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) {
DCHECK(CalledOnValidThread());
temporary_input_ptr_ = std::move(input_ptr);
@@ -226,6 +251,7 @@ void ArcBridgeService::CloseAllChannels() {
// Call all the error handlers of all the channels to both close the channel
// and notify any observers that the channel is closed.
CloseAppChannel();
+ CloseClipboardChannel();
CloseInputChannel();
CloseNotificationsChannel();
ClosePowerChannel();

Powered by Google App Engine
This is Rietveld 408576698