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

Unified Diff: ash/public/cpp/shelf_struct_traits.cc

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Restore AppLaunchId class via using ShelfID = AppLaunchId; cleanup. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698