| OLD | NEW |
| 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/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "components/arc/arc_session_runner.h" | |
| 15 | 14 |
| 16 namespace arc { | 15 namespace arc { |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 const base::Feature kArcEnabledFeature{"EnableARC", | 19 const base::Feature kArcEnabledFeature{"EnableARC", |
| 21 base::FEATURE_DISABLED_BY_DEFAULT}; | 20 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 22 | 21 |
| 23 } // namespace | 22 } // namespace |
| 24 | 23 |
| 25 ArcBridgeService::ArcBridgeService() = default; | 24 ArcBridgeService::ArcBridgeService() = default; |
| 26 | 25 |
| 27 ArcBridgeService::~ArcBridgeService() = default; | 26 ArcBridgeService::~ArcBridgeService() = default; |
| 28 | 27 |
| 29 // static | 28 // static |
| 30 bool ArcBridgeService::GetEnabled(const base::CommandLine* command_line) { | 29 bool ArcBridgeService::GetEnabled(const base::CommandLine* command_line) { |
| 31 return command_line->HasSwitch(chromeos::switches::kEnableArc) || | 30 return command_line->HasSwitch(chromeos::switches::kEnableArc) || |
| 32 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && | 31 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && |
| 33 base::FeatureList::IsEnabled(kArcEnabledFeature)); | 32 base::FeatureList::IsEnabled(kArcEnabledFeature)); |
| 34 } | 33 } |
| 35 | 34 |
| 36 // static | 35 // static |
| 37 bool ArcBridgeService::GetAvailable(const base::CommandLine* command_line) { | 36 bool ArcBridgeService::GetAvailable(const base::CommandLine* command_line) { |
| 38 return command_line->HasSwitch(chromeos::switches::kArcAvailable); | 37 return command_line->HasSwitch(chromeos::switches::kArcAvailable); |
| 39 } | 38 } |
| 40 | 39 |
| 41 void ArcBridgeService::InitializeArcSessionRunner( | |
| 42 std::unique_ptr<ArcSessionRunner> arc_session_runner) { | |
| 43 DCHECK(!arc_session_runner_); | |
| 44 arc_session_runner_ = std::move(arc_session_runner); | |
| 45 } | |
| 46 | |
| 47 void ArcBridgeService::AddObserver(ArcSessionObserver* observer) { | |
| 48 DCHECK(arc_session_runner_); | |
| 49 arc_session_runner_->AddObserver(observer); | |
| 50 } | |
| 51 | |
| 52 void ArcBridgeService::RemoveObserver(ArcSessionObserver* observer) { | |
| 53 DCHECK(arc_session_runner_); | |
| 54 arc_session_runner_->RemoveObserver(observer); | |
| 55 } | |
| 56 | |
| 57 void ArcBridgeService::RequestStart() { | |
| 58 DCHECK(arc_session_runner_); | |
| 59 arc_session_runner_->RequestStart(); | |
| 60 } | |
| 61 | |
| 62 void ArcBridgeService::RequestStop() { | |
| 63 DCHECK(arc_session_runner_); | |
| 64 arc_session_runner_->RequestStop(); | |
| 65 } | |
| 66 | |
| 67 void ArcBridgeService::OnShutdown() { | |
| 68 DCHECK(arc_session_runner_); | |
| 69 arc_session_runner_->OnShutdown(); | |
| 70 } | |
| 71 | |
| 72 bool ArcBridgeService::ready() const { | |
| 73 DCHECK(arc_session_runner_); | |
| 74 return arc_session_runner_->IsRunning(); | |
| 75 } | |
| 76 | |
| 77 bool ArcBridgeService::stopped() const { | |
| 78 DCHECK(arc_session_runner_); | |
| 79 return arc_session_runner_->IsStopped(); | |
| 80 } | |
| 81 | |
| 82 } // namespace arc | 40 } // namespace arc |
| OLD | NEW |