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

Side by Side Diff: components/arc/arc_bridge_service.cc

Issue 1553613002: Add ArcAuthService to handle IPC request from ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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::OnAuthInstanceReady(AuthInstancePtr auth_ptr) {
84 DCHECK(CalledOnValidThread());
85 temporary_auth_ptr_ = std::move(auth_ptr);
86 temporary_auth_ptr_.QueryVersion(base::Bind(
87 &ArcBridgeService::OnAuthVersionReady, weak_factory_.GetWeakPtr()));
88 }
89
90 void ArcBridgeService::OnAuthVersionReady(int32_t version) {
91 DCHECK(CalledOnValidThread());
92 auth_ptr_ = std::move(temporary_auth_ptr_);
93 FOR_EACH_OBSERVER(Observer, observer_list(), OnAuthInstanceReady());
94 auth_ptr_.set_connection_error_handler(base::Bind(
95 &ArcBridgeService::CloseAuthChannel, weak_factory_.GetWeakPtr()));
96 }
97
98 void ArcBridgeService::CloseAuthChannel() {
99 DCHECK(CalledOnValidThread());
100 if (!input_ptr_)
101 return;
102
103 auth_ptr_.reset();
104 FOR_EACH_OBSERVER(Observer, observer_list(), OnAuthInstanceClosed());
105 }
106
83 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { 107 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) {
84 DCHECK(CalledOnValidThread()); 108 DCHECK(CalledOnValidThread());
85 temporary_input_ptr_ = std::move(input_ptr); 109 temporary_input_ptr_ = std::move(input_ptr);
86 temporary_input_ptr_.QueryVersion(base::Bind( 110 temporary_input_ptr_.QueryVersion(base::Bind(
87 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr())); 111 &ArcBridgeService::OnInputVersionReady, weak_factory_.GetWeakPtr()));
88 } 112 }
89 113
90 void ArcBridgeService::OnInputVersionReady(int32_t version) { 114 void ArcBridgeService::OnInputVersionReady(int32_t version) {
91 DCHECK(CalledOnValidThread()); 115 DCHECK(CalledOnValidThread());
92 input_ptr_ = std::move(temporary_input_ptr_); 116 input_ptr_ = std::move(temporary_input_ptr_);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 243 }
220 244
221 bool ArcBridgeService::CalledOnValidThread() { 245 bool ArcBridgeService::CalledOnValidThread() {
222 return thread_checker_.CalledOnValidThread(); 246 return thread_checker_.CalledOnValidThread();
223 } 247 }
224 248
225 void ArcBridgeService::CloseAllChannels() { 249 void ArcBridgeService::CloseAllChannels() {
226 // Call all the error handlers of all the channels to both close the channel 250 // Call all the error handlers of all the channels to both close the channel
227 // and notify any observers that the channel is closed. 251 // and notify any observers that the channel is closed.
228 CloseAppChannel(); 252 CloseAppChannel();
253 CloseAuthChannel();
229 CloseInputChannel(); 254 CloseInputChannel();
230 CloseNotificationsChannel(); 255 CloseNotificationsChannel();
231 ClosePowerChannel(); 256 ClosePowerChannel();
232 CloseProcessChannel(); 257 CloseProcessChannel();
233 CloseSettingsChannel(); 258 CloseSettingsChannel();
234 } 259 }
235 260
236 } // namespace arc 261 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698