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

Unified Diff: components/arc/arc_bridge_service.cc

Issue 1408263006: chromeos: Add ArcInputBridge to components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@arcxx
Patch Set: added owners Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« components/arc/arc_bridge_service.h ('K') | « components/arc/arc_bridge_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_bridge_service.cc
diff --git a/components/arc/arc_bridge_service.cc b/components/arc/arc_bridge_service.cc
index 2bb34aca41a679786bbf0abbeee5696692d734aa..00e163268d9cbd5c2fa12fc8943bdb3dd1da6b38 100644
--- a/components/arc/arc_bridge_service.cc
+++ b/components/arc/arc_bridge_service.cc
@@ -129,16 +129,39 @@ void ArcBridgeService::RemoveObserver(Observer* observer) {
observer_list_.RemoveObserver(observer);
}
-bool ArcBridgeService::RegisterInputDevice(const std::string& name,
- const std::string& device_type,
- base::ScopedFD fd) {
- DCHECK(ipc_task_runner_->RunsTasksOnCurrentThread());
- if (state_ != State::READY) {
- LOG(ERROR) << "Called RegisterInputDevice when the service is not ready";
- return false;
+base::ScopedFD ArcBridgeService::CreateBridgeInputDevice(
+ const std::string& name,
+ const std::string& device_type) {
+ // Create file descriptor pair for communication
+ int fd[2];
+ if (pipe(fd) < 0) {
+ PLOG(ERROR) << "Cannot create pipe";
Luis Héctor Chávez 2015/11/17 17:51:53 At this point the operation cannot continue. retur
denniskempin 2015/11/19 19:22:09 Done.
+ }
+
+ // The read end is sent to the instance
+ ipc_channel_->Send(new ArcInstanceMsg_RegisterInputDevice(
Luis Héctor Chávez 2015/11/17 17:51:53 What if this fails (returns false)? Shouldn't you
denniskempin 2015/11/19 19:22:09 Done. I'm checking for errors and return -1 as a f
+ name, device_type, base::FileDescriptor(fd[0], true)));
+
+ // return the write end
+ return base::ScopedFD(fd[1]);
+}
+
+void ArcBridgeService::SetupBridgeInputDevices() {
+ bridge_devices_.push_back(new TouchscreenBridgeInputDevice(
+ CreateBridgeInputDevice("ChromeOS Touchscreen", "touchscreen")));
+ bridge_devices_.push_back(new MouseBridgeInputDevice(
+ CreateBridgeInputDevice("ChromeOS Mouse", "mouse")));
+ bridge_devices_.push_back(new KeyboardBridgeInputDevice(
+ CreateBridgeInputDevice("ChromeOS Keyboard", "keyboard")));
+}
+
+void ArcBridgeService::SendInputEvent(ui::Event* event) {
+ if (bridge_devices_.empty()) {
denniskempin 2015/11/16 18:55:49 NOTE: this is temporary until we have a CL that al
denniskempin 2015/11/19 19:22:09 removed.
+ SetupBridgeInputDevices();
+ }
+ for (BridgeInputDevice* device : bridge_devices_) {
+ device->OnEvent(event);
}
- return ipc_channel_->Send(new ArcInstanceMsg_RegisterInputDevice(
- name, device_type, base::FileDescriptor(fd.Pass())));
}
void ArcBridgeService::SocketConnect(const base::FilePath& socket_path) {
@@ -168,7 +191,6 @@ void ArcBridgeService::SocketConnectAfterEnsureParentDirectory(
StopInstance();
return;
}
-
if (!Connect(IPC::ChannelHandle(socket_path.value()),
IPC::Channel::MODE_OPEN_NAMED_SERVER)) {
LOG(ERROR) << "Error connecting to " << socket_path.value();
« components/arc/arc_bridge_service.h ('K') | « components/arc/arc_bridge_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698