James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/mojo_test_interface_factory.h" |
| 6 | |
| 7 | #include <utility> |
| 8 | |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 9 | #include "ash/metrics/time_to_first_present_recorder_test_api.h" |
Tetsui Ohkubo | 4f18619a | 2018-06-06 01:19:31 | [diff] [blame] | 10 | #include "ash/public/cpp/ash_features.h" |
James Cook | 8f09721 | 2017-11-09 00:18:54 | [diff] [blame] | 11 | #include "ash/public/interfaces/shelf_test_api.mojom.h" |
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 12 | #include "ash/public/interfaces/shell_test_api.mojom.h" |
Katie D | 9824f823 | 2018-05-08 00:22:33 | [diff] [blame] | 13 | #include "ash/public/interfaces/status_area_widget_test_api.mojom.h" |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 14 | #include "ash/public/interfaces/system_tray_test_api.mojom.h" |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 15 | #include "ash/public/interfaces/time_to_first_present_recorder_test_api.mojom.h" |
James Cook | 8f09721 | 2017-11-09 00:18:54 | [diff] [blame] | 16 | #include "ash/shelf/shelf_test_api.h" |
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 17 | #include "ash/shell_test_api.h" |
Katie D | 9824f823 | 2018-05-08 00:22:33 | [diff] [blame] | 18 | #include "ash/system/status_area_widget_test_api.h" |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 19 | #include "ash/system/tray/system_tray_test_api.h" |
Tetsui Ohkubo | 4f18619a | 2018-06-06 01:19:31 | [diff] [blame] | 20 | #include "ash/system/unified/unified_system_tray_test_api.h" |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 21 | #include "base/bind.h" |
| 22 | #include "base/single_thread_task_runner.h" |
| 23 | |
| 24 | namespace ash { |
| 25 | namespace mojo_test_interface_factory { |
| 26 | namespace { |
| 27 | |
James Cook | 8f09721 | 2017-11-09 00:18:54 | [diff] [blame] | 28 | // These functions aren't strictly necessary, but exist to make threading and |
| 29 | // arguments clearer. |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 30 | |
James Cook | 8f09721 | 2017-11-09 00:18:54 | [diff] [blame] | 31 | void BindShelfTestApiOnMainThread(mojom::ShelfTestApiRequest request) { |
| 32 | ShelfTestApi::BindRequest(std::move(request)); |
| 33 | } |
| 34 | |
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 35 | void BindShellTestApiOnMainThread(mojom::ShellTestApiRequest request) { |
| 36 | ShellTestApi::BindRequest(std::move(request)); |
| 37 | } |
| 38 | |
Katie D | 9824f823 | 2018-05-08 00:22:33 | [diff] [blame] | 39 | void BindStatusAreaWidgetTestApiOnMainThread( |
| 40 | mojom::StatusAreaWidgetTestApiRequest request) { |
| 41 | StatusAreaWidgetTestApi::BindRequest(std::move(request)); |
| 42 | } |
| 43 | |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 44 | void BindSystemTrayTestApiOnMainThread( |
| 45 | mojom::SystemTrayTestApiRequest request) { |
Tetsui Ohkubo | 4f18619a | 2018-06-06 01:19:31 | [diff] [blame] | 46 | if (features::IsSystemTrayUnifiedEnabled()) |
| 47 | UnifiedSystemTrayTestApi::BindRequest(std::move(request)); |
| 48 | else |
| 49 | SystemTrayTestApi::BindRequest(std::move(request)); |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 50 | } |
| 51 | |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 52 | void BindTimeToFirstPresentRecorderTestApiOnMainThread( |
| 53 | mojom::TimeToFirstPresentRecorderTestApiRequest request) { |
| 54 | TimeToFirstPresentRecorderTestApi::BindRequest(std::move(request)); |
| 55 | } |
| 56 | |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 57 | } // namespace |
| 58 | |
| 59 | void RegisterInterfaces( |
| 60 | service_manager::BinderRegistry* registry, |
| 61 | scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { |
James Cook | 8f09721 | 2017-11-09 00:18:54 | [diff] [blame] | 62 | registry->AddInterface(base::Bind(&BindShelfTestApiOnMainThread), |
| 63 | main_thread_task_runner); |
James Cook | 00848f0 | 2018-01-05 18:02:57 | [diff] [blame] | 64 | registry->AddInterface(base::Bind(&BindShellTestApiOnMainThread), |
| 65 | main_thread_task_runner); |
Katie D | 9824f823 | 2018-05-08 00:22:33 | [diff] [blame] | 66 | registry->AddInterface(base::Bind(&BindStatusAreaWidgetTestApiOnMainThread), |
| 67 | main_thread_task_runner); |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 68 | registry->AddInterface(base::Bind(&BindSystemTrayTestApiOnMainThread), |
| 69 | main_thread_task_runner); |
Scott Violet | 3c554ae | 2017-12-13 02:25:41 | [diff] [blame] | 70 | registry->AddInterface( |
| 71 | base::Bind(&BindTimeToFirstPresentRecorderTestApiOnMainThread), |
| 72 | main_thread_task_runner); |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 73 | } |
| 74 | |
James Cook | 625eff0 | 2017-10-11 20:44:31 | [diff] [blame] | 75 | } // namespace mojo_test_interface_factory |
| 76 | } // namespace ash |