Many developers have added utility functions to check if the many Mojo instances are ready and with the correct version, which seems redundant.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3faadf3336fe654e2cde8f16daacd136585026a1 commit 3faadf3336fe654e2cde8f16daacd136585026a1 Author: lhchavez <lhchavez@chromium.org> Date: Mon Sep 19 15:59:53 2016 arc: Add InstanceHelper::GetInstanceForMethod() Many developers have added utility functions to check if the many Mojo instances are ready and with the correct version, which seems redundant. This change adds a function to do that (and log failures). BUG= 647853 TEST=cheets_SettingsBridge Review-Url: https://codereview.chromium.org/2347293002 Cr-Commit-Position: refs/heads/master@{#419471} [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/chrome/browser/chromeos/arc/arc_wallpaper_service.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/chrome/browser/chromeos/arc/arc_wallpaper_service.h [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/chrome/browser/task_manager/providers/arc/arc_process_task.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/chrome/browser/ui/app_list/arc/arc_app_utils.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/bluetooth/arc_bluetooth_bridge.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/bluetooth/arc_bluetooth_bridge.h [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/ime/arc_ime_bridge_impl.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/instance_holder.h [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/net/arc_net_host_impl.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/storage_manager/arc_storage_manager.cc [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/components/arc/storage_manager/arc_storage_manager.h [modify] https://crrev.com/3faadf3336fe654e2cde8f16daacd136585026a1/ui/arc/notification/arc_notification_manager.cc
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/34ceeb456810e5f24f2f233e30d98423385cb614 commit 34ceeb456810e5f24f2f233e30d98423385cb614 Author: yusukes <yusukes@chromium.org> Date: Tue Sep 27 05:17:05 2016 Always use arc::InstanceHolder<T>::GetInstanceForMethod Previously, both arc::InstanceHolder<T>::instance() with some manual version checks (or without any version checks by mistake) and arc::InstanceHolder<T>::GetInstanceForMethod() are used for getting an instance pointer. This CL removes the former so that the relatively unsafe code won't be used as a template in the future. Details: * Use GetInstanceForMethod() even for Init (because it is not always true that Init is with MinVersion=0). Add missing version checks so that such code won't be copied when adding a new ARC service. * Add nullptr checks to all OnInstanceReady functions for consistency. * Change the return type of instance() from T* to bool and rename it to HasInstance() because all remaining instance() usages are inside if statement. * Remove version() to prevent developers from using the unary version of GetInstanceForMethod() and version(). * Change the log level for the version mismatch log in GetInstanceForMethod() from VLOG(2) to LOG(ERROR) because most of the existing code I removed in favor of GetInstanceForMethod's logging used LOG(ERROR). * Use uint32_t for min versions. * Add #includes to remove IWYU lint warnings BUG= 647853 TEST=try TEST=ARC still starts without any unexpected error logs. TBR=dmazzoni@chromium.org Review-Url: https://codereview.chromium.org/2357053002 Cr-Commit-Position: refs/heads/master@{#421113} [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_auth_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_downloads_watcher_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_navigation_throttle.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_policy_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_print_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_process_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_settings_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_tts_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/arc_wallpaper_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/chromeos/file_manager/arc_file_tasks.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/memory/tab_manager_delegate_chromeos.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/memory/tab_manager_delegate_chromeos.h [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/speech/tts_chromeos.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/sync/test/integration/sync_arc_package_helper.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/audio/arc_audio_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/bluetooth/arc_bluetooth_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/boot_phase_monitor/arc_boot_phase_monitor_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/clipboard/arc_clipboard_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/crash_collector/arc_crash_collector_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/ime/arc_ime_bridge_impl.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/instance_holder.h [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/intent_helper/activity_icon_loader.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/intent_helper/arc_intent_helper_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/intent_helper/arc_intent_helper_bridge.h [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/intent_helper/link_handler_model_impl.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/metrics/arc_metrics_service.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/net/arc_net_host_impl.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/obb_mounter/arc_obb_mounter_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/components/arc/power/arc_power_bridge.cc [modify] https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614/ui/arc/notification/arc_notification_manager.cc
Comment 1 by bugdroid1@chromium.org
, Sep 19 2016