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

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)

Created:
4 years, 3 months ago by Yusuke Sato
Modified:
4 years, 2 months ago
CC:
chromium-reviews, elijahtaylor+arcwatch_chromium.org, cbentzel+watch_chromium.org, ejcaruso+watch_chromium.org, yusukes+watch_chromium.org, abhishekbh_chromium.org, posciak+watch_chromium.org, tfarina, hidehiko+watch_chromium.org, dcheng, lhchavez+watch_chromium.org, Sameer Nanda, oshima+watch_chromium.org, Kevin Cernekee, davemoore+watch_chromium.org, Matt Giuca
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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 Committed: https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614 Cr-Commit-Position: refs/heads/master@{#421113}

Patch Set 1 #

Patch Set 2 : fix tests #

Patch Set 3 : review #

Total comments: 5

Patch Set 4 : rebased to catch up tot #

Total comments: 17

Patch Set 5 : Address comments from Luis #

Total comments: 4

Patch Set 6 : CHECK -> DCHECK #

Total comments: 7

Patch Set 7 : Address comments from Xiyuan #

Patch Set 8 : rebase, no code change #

Unified diffs Side-by-side diffs Delta from patch set Stats (+265 lines, -235 lines) Patch
M chrome/browser/chromeos/arc/arc_auth_service.cc View 1 2 3 4 5 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_downloads_watcher_service.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/arc/arc_enterprise_reporting_service.cc View 1 2 3 4 5 1 chunk +5 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc View 1 2 3 4 5 6 7 7 chunks +15 lines, -14 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_navigation_throttle.cc View 1 2 3 4 5 6 7 6 chunks +22 lines, -14 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_policy_bridge.cc View 1 2 3 4 5 3 chunks +8 lines, -8 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_print_service.cc View 1 2 3 4 5 1 chunk +2 lines, -6 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_process_service.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/arc/arc_settings_service.cc View 2 chunks +8 lines, -9 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_tts_service.cc View 1 2 3 4 5 1 chunk +3 lines, -6 lines 0 comments Download
M chrome/browser/chromeos/arc/arc_wallpaper_service.cc View 1 2 3 4 5 1 chunk +2 lines, -6 lines 0 comments Download
M chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc View 1 2 3 4 5 2 chunks +3 lines, -1 line 0 comments Download
M chrome/browser/chromeos/file_manager/arc_file_tasks.cc View 1 2 3 4 5 6 7 5 chunks +12 lines, -6 lines 0 comments Download
M chrome/browser/memory/tab_manager_delegate_chromeos.h View 3 chunks +3 lines, -14 lines 0 comments Download
M chrome/browser/memory/tab_manager_delegate_chromeos.cc View 6 chunks +12 lines, -25 lines 0 comments Download
M chrome/browser/speech/tts_chromeos.cc View 1 2 3 4 4 chunks +13 lines, -5 lines 0 comments Download
M chrome/browser/sync/test/integration/sync_arc_package_helper.cc View 1 2 3 chunks +6 lines, -2 lines 0 comments Download
M chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc View 1 2 3 4 5 6 5 chunks +17 lines, -8 lines 0 comments Download
M chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc View 1 2 3 4 5 6 3 chunks +19 lines, -5 lines 0 comments Download
M components/arc/audio/arc_audio_bridge.cc View 1 2 3 4 5 3 chunks +12 lines, -11 lines 0 comments Download
M components/arc/bluetooth/arc_bluetooth_bridge.cc View 1 2 3 4 5 1 chunk +3 lines, -7 lines 0 comments Download
M components/arc/boot_phase_monitor/arc_boot_phase_monitor_bridge.cc View 1 2 3 4 5 1 chunk +4 lines, -2 lines 0 comments Download
M components/arc/clipboard/arc_clipboard_bridge.cc View 1 2 3 4 5 2 chunks +6 lines, -7 lines 0 comments Download
M components/arc/crash_collector/arc_crash_collector_bridge.cc View 1 2 3 4 5 1 chunk +4 lines, -2 lines 0 comments Download
M components/arc/ime/arc_ime_bridge_impl.cc View 1 2 3 4 5 1 chunk +3 lines, -2 lines 0 comments Download
M components/arc/instance_holder.h View 1 2 3 4 4 chunks +13 lines, -12 lines 0 comments Download
M components/arc/intent_helper/activity_icon_loader.cc View 1 2 1 chunk +2 lines, -3 lines 0 comments Download
M components/arc/intent_helper/arc_intent_helper_bridge.h View 1 2 3 4 5 6 7 1 chunk +4 lines, -2 lines 0 comments Download
M components/arc/intent_helper/arc_intent_helper_bridge.cc View 1 2 3 4 5 6 7 3 chunks +17 lines, -13 lines 0 comments Download
M components/arc/intent_helper/link_handler_model_impl.cc View 1 2 3 4 5 6 7 3 chunks +8 lines, -9 lines 0 comments Download
M components/arc/metrics/arc_metrics_service.cc View 3 chunks +7 lines, -9 lines 0 comments Download
M components/arc/net/arc_net_host_impl.cc View 1 2 3 4 5 1 chunk +3 lines, -1 line 0 comments Download
M components/arc/obb_mounter/arc_obb_mounter_bridge.cc View 1 2 3 4 5 1 chunk +2 lines, -1 line 0 comments Download
M components/arc/power/arc_power_bridge.cc View 1 2 3 4 5 3 chunks +11 lines, -10 lines 0 comments Download
M ui/arc/notification/arc_notification_manager.cc View 1 2 3 4 5 4 chunks +8 lines, -8 lines 0 comments Download

Messages

Total messages: 59 (38 generated)
Yusuke Sato
Tried to detect instance() calls without proper version checks, and actually found many instances. Changed ...
4 years, 3 months ago (2016-09-21 18:27:48 UTC) #15
Yusuke Sato
https://codereview.chromium.org/2357053002/diff/40001/chrome/browser/chromeos/arc/arc_auth_service.cc File chrome/browser/chromeos/arc/arc_auth_service.cc (right): https://codereview.chromium.org/2357053002/diff/40001/chrome/browser/chromeos/arc/arc_auth_service.cc#newcode233 chrome/browser/chromeos/arc/arc_auth_service.cc:233: if (!instance) On 2016/09/21 18:27:48, Yusuke Sato wrote: > ...
4 years, 3 months ago (2016-09-22 22:26:28 UTC) #18
Luis Héctor Chávez
Thanks for doing this :D https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc File chrome/browser/chromeos/arc/arc_navigation_throttle.cc (right): https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc#newcode234 chrome/browser/chromeos/arc/arc_navigation_throttle.cc:234: "HandleUrl", kMinVersionForHandleUrl); nit: Given ...
4 years, 3 months ago (2016-09-23 22:51:04 UTC) #21
Luis Héctor Chávez
https://codereview.chromium.org/2357053002/diff/60001/components/arc/instance_holder.h File components/arc/instance_holder.h (right): https://codereview.chromium.org/2357053002/diff/60001/components/arc/instance_holder.h#newcode46 components/arc/instance_holder.h:46: uint32_t GetVersionForLogging() const { return version_; } On 2016/09/23 ...
4 years, 3 months ago (2016-09-23 23:22:45 UTC) #22
Yusuke Sato
Thanks for the review! PTAL. https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc File chrome/browser/chromeos/arc/arc_navigation_throttle.cc (right): https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc#newcode234 chrome/browser/chromeos/arc/arc_navigation_throttle.cc:234: "HandleUrl", kMinVersionForHandleUrl); On 2016/09/23 ...
4 years, 3 months ago (2016-09-24 00:15:23 UTC) #25
dcheng
https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc File chrome/browser/chromeos/arc/arc_auth_service.cc (right): https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc#newcode233 chrome/browser/chromeos/arc/arc_auth_service.cc:233: CHECK(instance); We should prefer DCHECK() over CHECK() to document ...
4 years, 3 months ago (2016-09-24 00:25:25 UTC) #27
dcheng
https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc File chrome/browser/chromeos/arc/arc_auth_service.cc (right): https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc#newcode233 chrome/browser/chromeos/arc/arc_auth_service.cc:233: CHECK(instance); On 2016/09/24 00:25:25, dcheng wrote: > We should ...
4 years, 3 months ago (2016-09-24 00:27:13 UTC) #29
Yusuke Sato
https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc File chrome/browser/chromeos/arc/arc_auth_service.cc (right): https://codereview.chromium.org/2357053002/diff/80001/chrome/browser/chromeos/arc/arc_auth_service.cc#newcode233 chrome/browser/chromeos/arc/arc_auth_service.cc:233: CHECK(instance); On 2016/09/24 00:25:25, dcheng wrote: > We should ...
4 years, 3 months ago (2016-09-24 00:50:54 UTC) #34
Luis Héctor Chávez
lgtm https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc File chrome/browser/chromeos/arc/arc_navigation_throttle.cc (right): https://codereview.chromium.org/2357053002/diff/60001/chrome/browser/chromeos/arc/arc_navigation_throttle.cc#newcode234 chrome/browser/chromeos/arc/arc_navigation_throttle.cc:234: "HandleUrl", kMinVersionForHandleUrl); On 2016/09/24 00:15:22, Yusuke Sato wrote: ...
4 years, 3 months ago (2016-09-24 02:00:00 UTC) #37
Yusuke Sato
+more owners. Owners, this is a cleanup for ARC. Please take a look. dmazzoni@ chrome/browser/speech/ ...
4 years, 2 months ago (2016-09-26 05:12:28 UTC) #39
xiyuan
https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc File chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc (right): https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc#newcode331 chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc:331: if (!app_instance) nit: Can this be a DCHECK, same ...
4 years, 2 months ago (2016-09-26 16:20:43 UTC) #40
Yusuke Sato
https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc File chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc (right): https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc#newcode331 chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc:331: if (!app_instance) On 2016/09/26 16:20:42, xiyuan wrote: > nit: ...
4 years, 2 months ago (2016-09-26 16:43:23 UTC) #41
xiyuan
lgtm c/b/ui/app_list/arc/ c/b/chromeos/file_manager/ https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc File chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc (right): https://codereview.chromium.org/2357053002/diff/100001/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc#newcode331 chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc:331: if (!app_instance) On 2016/09/26 16:43:22, Yusuke ...
4 years, 2 months ago (2016-09-26 16:45:54 UTC) #42
Georges Khalil
lgtm for chrome/browser/memory/
4 years, 2 months ago (2016-09-26 17:02:21 UTC) #45
pavely
chrome/browser/sync/test/integration/ lgtm
4 years, 2 months ago (2016-09-26 18:01:09 UTC) #48
Eric Caruso
components/arc/power/ lgtm
4 years, 2 months ago (2016-09-26 18:11:20 UTC) #49
Yusuke Sato
Thanks all. Dominic, please take a look at chrome/browser/speech/.
4 years, 2 months ago (2016-09-26 19:35:12 UTC) #50
Yusuke Sato
Let me land this with TBR=dmazzoni as this is not really a TTS change but ...
4 years, 2 months ago (2016-09-27 05:11:18 UTC) #52
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2357053002/140001
4 years, 2 months ago (2016-09-27 05:11:46 UTC) #55
commit-bot: I haz the power
Committed patchset #8 (id:140001)
4 years, 2 months ago (2016-09-27 05:17:26 UTC) #57
commit-bot: I haz the power
4 years, 2 months ago (2016-09-27 05:19:33 UTC) #59
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/34ceeb456810e5f24f2f233e30d98423385cb614
Cr-Commit-Position: refs/heads/master@{#421113}

Powered by Google App Engine
This is Rietveld 408576698