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

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: Rebased and address review comments 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
« no previous file with comments | « components/arc/arc_bridge_service.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 void ArcBridgeService::CloseAuthChannel() { 98 void ArcBridgeService::CloseAuthChannel() {
99 DCHECK(CalledOnValidThread()); 99 DCHECK(CalledOnValidThread());
100 if (!input_ptr_) 100 if (!input_ptr_)
101 return; 101 return;
102 102
103 auth_ptr_.reset(); 103 auth_ptr_.reset();
104 FOR_EACH_OBSERVER(Observer, observer_list(), OnAuthInstanceClosed()); 104 FOR_EACH_OBSERVER(Observer, observer_list(), OnAuthInstanceClosed());
105 } 105 }
106 106
107 void ArcBridgeService::OnClipboardInstanceReady(
108 ClipboardInstancePtr clipboard_ptr) {
109 DCHECK(CalledOnValidThread());
110 temporary_clipboard_ptr_ = std::move(clipboard_ptr);
111 temporary_clipboard_ptr_.QueryVersion(base::Bind(
112 &ArcBridgeService::OnClipboardVersionReady, weak_factory_.GetWeakPtr()));
113 }
114
115 void ArcBridgeService::OnClipboardVersionReady(int32_t version) {
116 DCHECK(CalledOnValidThread());
117 clipboard_ptr_ = std::move(temporary_clipboard_ptr_);
118 FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceReady());
119 clipboard_ptr_.set_connection_error_handler(base::Bind(
120 &ArcBridgeService::CloseClipboardChannel, weak_factory_.GetWeakPtr()));
121 }
122
123 void ArcBridgeService::CloseClipboardChannel() {
124 DCHECK(CalledOnValidThread());
125 if (!clipboard_ptr_)
126 return;
127
128 clipboard_ptr_.reset();
129 FOR_EACH_OBSERVER(Observer, observer_list(), OnClipboardInstanceClosed());
130 }
131
107 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { 132 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) {
108 DCHECK(CalledOnValidThread()); 133 DCHECK(CalledOnValidThread());
109 temporary_input_ptr_ = std::move(input_ptr); 134 temporary_input_ptr_ = std::move(input_ptr);
110 temporary_input_ptr_.QueryVersion(base::Bind( 135 temporary_input_ptr_.QueryVersion(base::Bind(
111 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr())); 136 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr()));
112 } 137 }
113 138
114 void ArcBridgeService::OnInputVersionReady(int32_t version) { 139 void ArcBridgeService::OnInputVersionReady(int32_t version) {
115 DCHECK(CalledOnValidThread()); 140 DCHECK(CalledOnValidThread());
116 input_ptr_ = std::move(temporary_input_ptr_); 141 input_ptr_ = std::move(temporary_input_ptr_);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 269
245 bool ArcBridgeService::CalledOnValidThread() { 270 bool ArcBridgeService::CalledOnValidThread() {
246 return thread_checker_.CalledOnValidThread(); 271 return thread_checker_.CalledOnValidThread();
247 } 272 }
248 273
249 void ArcBridgeService::CloseAllChannels() { 274 void ArcBridgeService::CloseAllChannels() {
250 // Call all the error handlers of all the channels to both close the channel 275 // Call all the error handlers of all the channels to both close the channel
251 // and notify any observers that the channel is closed. 276 // and notify any observers that the channel is closed.
252 CloseAppChannel(); 277 CloseAppChannel();
253 CloseAuthChannel(); 278 CloseAuthChannel();
279 CloseClipboardChannel();
254 CloseInputChannel(); 280 CloseInputChannel();
255 CloseNotificationsChannel(); 281 CloseNotificationsChannel();
256 ClosePowerChannel(); 282 ClosePowerChannel();
257 CloseProcessChannel(); 283 CloseProcessChannel();
258 CloseSettingsChannel(); 284 CloseSettingsChannel();
259 } 285 }
260 286
261 } // namespace arc 287 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service.h ('k') | components/arc/arc_service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698