| 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 "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 SetState(State::STOPPING); | 118 SetState(State::STOPPING); |
| 119 chromeos::SessionManagerClient* session_manager_client = | 119 chromeos::SessionManagerClient* session_manager_client = |
| 120 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 120 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 121 session_manager_client->StopArcInstance(base::Bind( | 121 session_manager_client->StopArcInstance(base::Bind( |
| 122 &ArcBridgeService::OnInstanceStopped, weak_factory_.GetWeakPtr())); | 122 &ArcBridgeService::OnInstanceStopped, weak_factory_.GetWeakPtr())); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool ArcBridgeService::RegisterInputDevice(const std::string& name, | 125 bool ArcBridgeService::RegisterInputDevice(const std::string& name, |
| 126 const std::string& device_type, | 126 const std::string& device_type, |
| 127 base::ScopedFD fd) { | 127 base::ScopedFD fd) { |
| 128 DCHECK(ipc_task_runner_->RunsTasksOnCurrentThread()); | |
| 129 if (state_ != State::READY) { | |
| 130 LOG(ERROR) << "Called RegisterInputDevice when the service is not ready"; | |
| 131 return false; | |
| 132 } | |
| 133 return ipc_channel_->Send(new ArcInstanceMsg_RegisterInputDevice( | 128 return ipc_channel_->Send(new ArcInstanceMsg_RegisterInputDevice( |
| 134 name, device_type, base::FileDescriptor(fd.Pass()))); | 129 name, device_type, base::FileDescriptor(fd.release(), true))); |
| 135 } | 130 } |
| 136 | 131 |
| 137 void ArcBridgeService::SocketConnect(const base::FilePath& socket_path) { | 132 void ArcBridgeService::SocketConnect(const base::FilePath& socket_path) { |
| 138 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); | 133 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); |
| 139 if (state_ != State::STOPPED) { | 134 if (state_ != State::STOPPED) { |
| 140 VLOG(1) << "SocketConnect() called when instance is not stopped"; | 135 VLOG(1) << "SocketConnect() called when instance is not stopped"; |
| 141 return; | 136 return; |
| 142 } | 137 } |
| 143 SetState(State::CONNECTING); | 138 SetState(State::CONNECTING); |
| 144 base::PostTaskAndReplyWithResult( | 139 base::PostTaskAndReplyWithResult( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void ArcBridgeService::OnInstanceStopped(bool success) { | 273 void ArcBridgeService::OnInstanceStopped(bool success) { |
| 279 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); | 274 DCHECK(origin_task_runner_->RunsTasksOnCurrentThread()); |
| 280 // STOPPING is the only valid state for this function. | 275 // STOPPING is the only valid state for this function. |
| 281 // DCHECK on enum classes not supported. | 276 // DCHECK on enum classes not supported. |
| 282 DCHECK(state_ == State::STOPPING); | 277 DCHECK(state_ == State::STOPPING); |
| 283 ipc_channel_.reset(); | 278 ipc_channel_.reset(); |
| 284 SetState(State::STOPPED); | 279 SetState(State::STOPPED); |
| 285 } | 280 } |
| 286 | 281 |
| 287 } // namespace arc | 282 } // namespace arc |
| OLD | NEW |