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

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

Issue 1596663002: arc-bridge: Introduce the ArcService class (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Moved race avoidance boilerplate to ArcBridgeService 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 // static 44 // static
45 bool ArcBridgeService::GetEnabled(const base::CommandLine* command_line) { 45 bool ArcBridgeService::GetEnabled(const base::CommandLine* command_line) {
46 return command_line->HasSwitch(chromeos::switches::kEnableArc); 46 return command_line->HasSwitch(chromeos::switches::kEnableArc);
47 } 47 }
48 48
49 void ArcBridgeService::AddObserver(Observer* observer) { 49 void ArcBridgeService::AddObserver(Observer* observer) {
50 DCHECK(CalledOnValidThread()); 50 DCHECK(CalledOnValidThread());
51 observer_list_.AddObserver(observer); 51 observer_list_.AddObserver(observer);
52
53 // If any of the instances were ready before the call to AddObserver(), the
54 // |observer| won't get any readiness events. For such cases, we have to call
55 // them explicitly now to avoid a race.
56 if (app_instance())
57 observer->OnAppInstanceReady();
58 if (auth_instance())
59 observer->OnAuthInstanceReady();
60 if (clipboard_instance())
61 observer->OnClipboardInstanceReady();
62 if (ime_instance())
63 observer->OnImeInstanceReady();
64 if (input_instance())
65 observer->OnInputInstanceReady();
66 if (notifications_instance())
67 observer->OnNotificationsInstanceReady();
68 if (power_instance())
69 observer->OnPowerInstanceReady();
70 if (process_instance())
71 observer->OnProcessInstanceReady();
72 if (settings_instance())
73 observer->OnSettingsInstanceReady();
74 if (video_instance())
75 observer->OnVideoInstanceReady();
52 } 76 }
53 77
54 void ArcBridgeService::RemoveObserver(Observer* observer) { 78 void ArcBridgeService::RemoveObserver(Observer* observer) {
55 DCHECK(CalledOnValidThread()); 79 DCHECK(CalledOnValidThread());
56 observer_list_.RemoveObserver(observer); 80 observer_list_.RemoveObserver(observer);
57 } 81 }
58 82
59 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) { 83 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) {
60 DCHECK(CalledOnValidThread()); 84 DCHECK(CalledOnValidThread());
61 temporary_app_ptr_ = std::move(app_ptr); 85 temporary_app_ptr_ = std::move(app_ptr);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 CloseImeChannel(); 353 CloseImeChannel();
330 CloseInputChannel(); 354 CloseInputChannel();
331 CloseNotificationsChannel(); 355 CloseNotificationsChannel();
332 ClosePowerChannel(); 356 ClosePowerChannel();
333 CloseProcessChannel(); 357 CloseProcessChannel();
334 CloseSettingsChannel(); 358 CloseSettingsChannel();
335 CloseVideoChannel(); 359 CloseVideoChannel();
336 } 360 }
337 361
338 } // namespace arc 362 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698