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

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

Issue 1572483002: Implement OnGetNetworks for net.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing OnNetInstanceReady and CloseNetChannel calls 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (app_instance()) 56 if (app_instance())
57 observer->OnAppInstanceReady(); 57 observer->OnAppInstanceReady();
58 if (auth_instance()) 58 if (auth_instance())
59 observer->OnAuthInstanceReady(); 59 observer->OnAuthInstanceReady();
60 if (clipboard_instance()) 60 if (clipboard_instance())
61 observer->OnClipboardInstanceReady(); 61 observer->OnClipboardInstanceReady();
62 if (ime_instance()) 62 if (ime_instance())
63 observer->OnImeInstanceReady(); 63 observer->OnImeInstanceReady();
64 if (input_instance()) 64 if (input_instance())
65 observer->OnInputInstanceReady(); 65 observer->OnInputInstanceReady();
66 if (net_instance())
67 observer->OnNetInstanceReady();
66 if (notifications_instance()) 68 if (notifications_instance())
67 observer->OnNotificationsInstanceReady(); 69 observer->OnNotificationsInstanceReady();
68 if (power_instance()) 70 if (power_instance())
69 observer->OnPowerInstanceReady(); 71 observer->OnPowerInstanceReady();
70 if (process_instance()) 72 if (process_instance())
71 observer->OnProcessInstanceReady(); 73 observer->OnProcessInstanceReady();
72 if (settings_instance()) 74 if (settings_instance())
73 observer->OnSettingsInstanceReady(); 75 observer->OnSettingsInstanceReady();
74 if (video_instance()) 76 if (video_instance())
75 observer->OnVideoInstanceReady(); 77 observer->OnVideoInstanceReady();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 222
221 void ArcBridgeService::CloseIntentHelperChannel() { 223 void ArcBridgeService::CloseIntentHelperChannel() {
222 DCHECK(CalledOnValidThread()); 224 DCHECK(CalledOnValidThread());
223 if (!intent_helper_ptr_) 225 if (!intent_helper_ptr_)
224 return; 226 return;
225 227
226 intent_helper_ptr_.reset(); 228 intent_helper_ptr_.reset();
227 FOR_EACH_OBSERVER(Observer, observer_list(), OnIntentHelperInstanceClosed()); 229 FOR_EACH_OBSERVER(Observer, observer_list(), OnIntentHelperInstanceClosed());
228 } 230 }
229 231
232 void ArcBridgeService::OnNetInstanceReady(NetInstancePtr net_ptr) {
233 DCHECK(CalledOnValidThread());
234 temporary_net_ptr_ = std::move(net_ptr);
235 temporary_net_ptr_.QueryVersion(base::Bind(
236 &ArcBridgeService::OnNetVersionReady, weak_factory_.GetWeakPtr()));
237 }
238
239 void ArcBridgeService::OnNetVersionReady(int32_t version) {
240 DCHECK(CalledOnValidThread());
241 net_ptr_ = std::move(temporary_net_ptr_);
242 net_ptr_.set_connection_error_handler(base::Bind(
243 &ArcBridgeService::CloseNetChannel, weak_factory_.GetWeakPtr()));
244 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceReady());
245 }
246
247 void ArcBridgeService::CloseNetChannel() {
248 DCHECK(CalledOnValidThread());
249 if (!net_ptr_)
250 return;
251
252 net_ptr_.reset();
253 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceClosed());
254 }
255
230 void ArcBridgeService::OnNotificationsInstanceReady( 256 void ArcBridgeService::OnNotificationsInstanceReady(
231 NotificationsInstancePtr notifications_ptr) { 257 NotificationsInstancePtr notifications_ptr) {
232 DCHECK(CalledOnValidThread()); 258 DCHECK(CalledOnValidThread());
233 temporary_notifications_ptr_ = std::move(notifications_ptr); 259 temporary_notifications_ptr_ = std::move(notifications_ptr);
234 temporary_notifications_ptr_.QueryVersion( 260 temporary_notifications_ptr_.QueryVersion(
235 base::Bind(&ArcBridgeService::OnNotificationsVersionReady, 261 base::Bind(&ArcBridgeService::OnNotificationsVersionReady,
236 weak_factory_.GetWeakPtr())); 262 weak_factory_.GetWeakPtr()));
237 } 263 }
238 264
239 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) { 265 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 398
373 void ArcBridgeService::CloseAllChannels() { 399 void ArcBridgeService::CloseAllChannels() {
374 // Call all the error handlers of all the channels to both close the channel 400 // Call all the error handlers of all the channels to both close the channel
375 // and notify any observers that the channel is closed. 401 // and notify any observers that the channel is closed.
376 CloseAppChannel(); 402 CloseAppChannel();
377 CloseAuthChannel(); 403 CloseAuthChannel();
378 CloseClipboardChannel(); 404 CloseClipboardChannel();
379 CloseImeChannel(); 405 CloseImeChannel();
380 CloseInputChannel(); 406 CloseInputChannel();
381 CloseIntentHelperChannel(); 407 CloseIntentHelperChannel();
408 CloseNetChannel();
382 CloseNotificationsChannel(); 409 CloseNotificationsChannel();
383 ClosePowerChannel(); 410 ClosePowerChannel();
384 CloseProcessChannel(); 411 CloseProcessChannel();
385 CloseSettingsChannel(); 412 CloseSettingsChannel();
386 CloseVideoChannel(); 413 CloseVideoChannel();
387 } 414 }
388 415
389 } // namespace arc 416 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698