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

Issue 598013003: Added views::ViewModelT<T>, a type-safe template version of ViewModel. (Closed)

Created:
6 years, 2 months ago by Matt Giuca
Modified:
6 years, 2 months ago
Reviewers:
sky
CC:
chromium-reviews, chrome-apps-syd-reviews_chromium.org, kalyank, sadrul, ben+ash_chromium.org, tfarina, tapted
Base URL:
https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Project:
chromium
Visibility:
Public.

Description

Added views::ViewModelT<T>, a type-safe template version of ViewModel. A common use of views::ViewModel is to call view_at() then static_cast down to the correct type, which is unsafe. ViewModel clients are now encouraged to use ViewModelT<T> for compile-time type-checked access to the views inside. ViewModel still exists for clients that don't care about the view type, or with more complex downcasting logic. Updated clients, where possible, to use ViewModelT: TabStrip: ViewModelT<Tab> AppsGridView: ViewModelT<AppListItemView>, ViewModelT<PulsingBlockView>. BUG=418461 Committed: https://crrev.com/eee145893892eb15a42409c3d2e525b9f1e837e2 Cr-Commit-Position: refs/heads/master@{#297979}

Patch Set 1 #

Total comments: 2

Patch Set 2 : ViewModel is now a thin wrapper around ViewModelBase, implemented in the .cc file. #

Patch Set 3 : view_model_utils: Inline the methods. #

Patch Set 4 : ViewModelBase has a protected constructor. #

Patch Set 5 : Forgot to add view_model.cc back. #

Patch Set 6 : Rebase. #

Patch Set 7 : ViewModelUtils is now non-templated. #

Patch Set 8 : DISALLOW_COPY_AND_ASSIGN. #

Total comments: 6

Patch Set 9 : TEMP: Remove changes to view_model.cc and view_model_utils.cc to try to make Rietveld behave. #

Patch Set 10 : Same as Patch Set 8. Maybe Rietveld will behave. #

Patch Set 11 : Implement sky's suggestions (friend; ViewModelT and typedef ViewModel). #

Patch Set 12 : Fix StackedTabScriptLayoutTest (do not require a ViewModelT<Tab>). #

Patch Set 13 : Fix browser_test compile on ChromeOS (missing include). #

Unified diffs Side-by-side diffs Delta from patch set Stats (+114 lines, -88 lines) Patch
M ash/shelf/shelf_view.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +1 line, -1 line 0 comments Download
M chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +7 lines, -3 lines 0 comments Download
M chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +5 lines, -5 lines 0 comments Download
M chrome/browser/ui/views/tabs/stacked_tab_strip_layout.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/tabs/tab_strip.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -4 lines 0 comments Download
M ui/app_list/views/app_list_folder_view.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -4 lines 0 comments Download
M ui/app_list/views/app_list_main_view_unittest.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +7 lines, -5 lines 0 comments Download
M ui/app_list/views/apps_grid_view.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +7 lines, -9 lines 0 comments Download
M ui/app_list/views/apps_grid_view.cc View 1 2 3 4 5 3 chunks +2 lines, -6 lines 0 comments Download
M ui/app_list/views/contents_view.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -4 lines 0 comments Download
M ui/views/view_model.h View 1 2 3 4 5 6 7 8 9 10 4 chunks +54 lines, -20 lines 0 comments Download
M ui/views/view_model.cc View 1 2 3 4 9 5 chunks +17 lines, -17 lines 0 comments Download
M ui/views/view_model_utils.h View 1 2 3 4 5 6 2 chunks +4 lines, -4 lines 0 comments Download
M ui/views/view_model_utils.cc View 1 2 3 4 5 6 9 2 chunks +5 lines, -5 lines 0 comments Download

Messages

Total messages: 38 (14 generated)
Matt Giuca
Hi Scott, What do you think of this proposal. See the bug for a bit ...
6 years, 2 months ago (2014-09-29 07:15:53 UTC) #2
sky
What are the effects on code size here? https://codereview.chromium.org/598013003/diff/1/ui/views/view_model.h File ui/views/view_model.h (right): https://codereview.chromium.org/598013003/diff/1/ui/views/view_model.h#newcode99 ui/views/view_model.h:99: ViewModel<T>::ViewModel() ...
6 years, 2 months ago (2014-09-29 17:54:52 UTC) #3
Matt Giuca
tapted suggested that I make a ViewModelBase class (non-templated) and then provide a ViewModel<T> subclass, ...
6 years, 2 months ago (2014-09-30 04:30:41 UTC) #4
sky
I think I think tapted's suggestion, but I'm not sure it addresses what you are ...
6 years, 2 months ago (2014-09-30 13:17:25 UTC) #5
Matt Giuca
On 2014/09/30 13:17:25, sky wrote: > I think I think tapted's suggestion, but I'm not ...
6 years, 2 months ago (2014-10-01 03:07:03 UTC) #6
sky
https://codereview.chromium.org/598013003/diff/140001/ui/views/view_model.cc File ui/views/view_model.cc (left): https://codereview.chromium.org/598013003/diff/140001/ui/views/view_model.cc#oldcode1 ui/views/view_model.cc:1: // Copyright (c) 2012 The Chromium Authors. All rights ...
6 years, 2 months ago (2014-10-01 19:20:38 UTC) #7
Matt Giuca
https://codereview.chromium.org/598013003/diff/140001/ui/views/view_model.cc File ui/views/view_model.cc (left): https://codereview.chromium.org/598013003/diff/140001/ui/views/view_model.cc#oldcode1 ui/views/view_model.cc:1: // Copyright (c) 2012 The Chromium Authors. All rights ...
6 years, 2 months ago (2014-10-02 01:23:51 UTC) #8
sky
LGTM
6 years, 2 months ago (2014-10-02 02:28:47 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/200001
6 years, 2 months ago (2014-10-02 02:39:11 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_swarming on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_swarming/builds/19908)
6 years, 2 months ago (2014-10-02 03:26:35 UTC) #13
Matt Giuca
FYI, I made a slight change to StackedTabStripLayout in Patch Set 12 to fix a ...
6 years, 2 months ago (2014-10-02 08:00:19 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/220001
6 years, 2 months ago (2014-10-02 08:01:10 UTC) #16
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_rel on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_rel/builds/20947) win_chromium_x64_rel_swarming on tryserver.chromium.win (http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_rel_swarming/builds/15144)
6 years, 2 months ago (2014-10-02 08:08:42 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/220001
6 years, 2 months ago (2014-10-02 09:40:07 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_swarming on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_swarming/builds/20006)
6 years, 2 months ago (2014-10-02 09:53:20 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/220001
6 years, 2 months ago (2014-10-02 11:59:21 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_swarming on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_swarming/builds/20047)
6 years, 2 months ago (2014-10-02 12:30:50 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/220001
6 years, 2 months ago (2014-10-02 14:22:46 UTC) #28
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_swarming on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_swarming/builds/20109)
6 years, 2 months ago (2014-10-02 15:07:22 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/240001
6 years, 2 months ago (2014-10-03 00:46:34 UTC) #32
commit-bot: I haz the power
Try jobs failed on following builders: ios_rel_device_ninja on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/ios_rel_device_ninja/builds/15560)
6 years, 2 months ago (2014-10-03 01:53:55 UTC) #34
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/598013003/240001
6 years, 2 months ago (2014-10-03 02:40:21 UTC) #36
commit-bot: I haz the power
Committed patchset #13 (id:240001) as 97f03e451a031e5e0f533a7eb3e265d89db60951
6 years, 2 months ago (2014-10-03 02:51:09 UTC) #37
commit-bot: I haz the power
6 years, 2 months ago (2014-10-03 02:51:48 UTC) #38
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/eee145893892eb15a42409c3d2e525b9f1e837e2
Cr-Commit-Position: refs/heads/master@{#297979}

Powered by Google App Engine
This is Rietveld 408576698