Index: ash/public/cpp/shelf_struct_traits.cc |
diff --git a/ash/public/cpp/shelf_struct_traits.cc b/ash/public/cpp/shelf_struct_traits.cc |
index 001bfa516b7dc0432b242f863d2bb0b3f39de445..0174c28c95bcd5bd2dea7513ee3782d75637dc77 100644 |
--- a/ash/public/cpp/shelf_struct_traits.cc |
+++ b/ash/public/cpp/shelf_struct_traits.cc |
@@ -14,6 +14,18 @@ using ShelfItemStructTraits = |
StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem>; |
// static |
+bool StructTraits<ash::mojom::ShelfIDDataView, ash::ShelfID>::Read( |
+ ash::mojom::ShelfIDDataView data, |
+ ash::ShelfID* out) { |
+ std::string app_id; |
+ std::string launch_id; |
+ if (!data.ReadAppId(&app_id) || !data.ReadLaunchId(&launch_id)) |
+ return false; |
+ *out = ash::ShelfID(app_id, launch_id); |
James Cook
2017/05/04 16:38:48
Reading a ShelfID looks like it allocates and copi
msw
2017/05/04 19:05:56
WDYT about instead making AppLaunchId a struct wit
James Cook
2017/05/04 19:45:07
Yeah, I think making ShelfID / AppLaunchId a struc
msw
2017/05/04 20:39:07
Done.
|
+ return true; |
+} |
+ |
+// static |
const SkBitmap& ShelfItemStructTraits::image(const ash::ShelfItem& i) { |
// TODO(crbug.com/655874): Remove this when we have a gfx::Image[Skia] mojom. |
static const SkBitmap kNullSkBitmap; |
@@ -24,15 +36,11 @@ const SkBitmap& ShelfItemStructTraits::image(const ash::ShelfItem& i) { |
bool ShelfItemStructTraits::Read(ash::mojom::ShelfItemDataView data, |
ash::ShelfItem* out) { |
SkBitmap image; |
- std::string app_id; |
- std::string launch_id; |
if (!data.ReadType(&out->type) || !data.ReadImage(&image) || |
- !data.ReadStatus(&out->status) || !data.ReadAppId(&app_id) || |
- !data.ReadLaunchId(&launch_id) || !data.ReadTitle(&out->title)) { |
+ !data.ReadStatus(&out->status) || !data.ReadShelfId(&out->id) || |
+ !data.ReadTitle(&out->title)) { |
return false; |
} |
- out->id = data.shelf_id(); |
- out->app_launch_id = ash::AppLaunchId(app_id, launch_id); |
// TODO(crbug.com/655874): Support high-dpi images via gfx::Image[Skia] mojom. |
out->image = gfx::ImageSkia::CreateFrom1xBitmap(image); |
out->shows_tooltip = data.shows_tooltip(); |