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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/arc/arc_bridge_service.h" 5 #include "components/arc/arc_bridge_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 void ArcBridgeService::CloseAppChannel() { 74 void ArcBridgeService::CloseAppChannel() {
75 DCHECK(CalledOnValidThread()); 75 DCHECK(CalledOnValidThread());
76 if (!app_ptr_) 76 if (!app_ptr_)
77 return; 77 return;
78 78
79 app_ptr_.reset(); 79 app_ptr_.reset();
80 FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceClosed()); 80 FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceClosed());
81 } 81 }
82 82
83 void ArcBridgeService::OnClipboardInstanceReady(
84 ClipboardInstancePtr clipboard_ptr) {
85 DCHECK(CalledOnValidThread());
86 temporary_clipboard_ptr_ = std::move(clipboard_ptr);
87 temporary_clipboard_ptr_.QueryVersion(base::Bind(
88 &ArcBridgeService::OnClipboardVersionReady, weak_factory_.GetWeakPtr()));
89 }
90
91 void ArcBridgeService::OnClipboardVersionReady(int32_t version) {
92 DCHECK(CalledOnValidThread());
93 clipboard_ptr_ = std::move(temporary_clipboard_ptr_);
94 FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceReady());
95 clipboard_ptr_.set_connection_error_handler(base::Bind(
96 &ArcBridgeService::CloseClipboardChannel, weak_factory_.GetWeakPtr()));
97 }
98
99 void ArcBridgeService::CloseClipboardChannel() {
100 DCHECK(CalledOnValidThread());
101 if (!clipboard_ptr_)
102 return;
103
104 clipboard_ptr_.reset();
105 FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceClosed());
106 }
107
83 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { 108 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) {
84 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
85 temporary_input_ptr_ = std::move(input_ptr); 110 temporary_input_ptr_ = std::move(input_ptr);
86 temporary_input_ptr_.QueryVersion(base::Bind( 111 temporary_input_ptr_.QueryVersion(base::Bind(
87 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr())); 112 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr()));
88 } 113 }
89 114
90 void ArcBridgeService::OnInputVersionReady(int32_t version) { 115 void ArcBridgeService::OnInputVersionReady(int32_t version) {
91 DCHECK(CalledOnValidThread()); 116 DCHECK(CalledOnValidThread());
92 input_ptr_ = std::move(temporary_input_ptr_); 117 input_ptr_ = std::move(temporary_input_ptr_);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 244 }
220 245
221 bool ArcBridgeService::CalledOnValidThread() { 246 bool ArcBridgeService::CalledOnValidThread() {
222 return thread_checker_.CalledOnValidThread(); 247 return thread_checker_.CalledOnValidThread();
223 } 248 }
224 249
225 void ArcBridgeService::CloseAllChannels() { 250 void ArcBridgeService::CloseAllChannels() {
226 // Call all the error handlers of all the channels to both close the channel 251 // Call all the error handlers of all the channels to both close the channel
227 // and notify any observers that the channel is closed. 252 // and notify any observers that the channel is closed.
228 CloseAppChannel(); 253 CloseAppChannel();
254 CloseClipboardChannel();
229 CloseInputChannel(); 255 CloseInputChannel();
230 CloseNotificationsChannel(); 256 CloseNotificationsChannel();
231 ClosePowerChannel(); 257 ClosePowerChannel();
232 CloseProcessChannel(); 258 CloseProcessChannel();
233 CloseSettingsChannel(); 259 CloseSettingsChannel();
234 } 260 }
235 261
236 } // namespace arc 262 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698