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

Unified Diff: components/arc/wallpaper/arc_wallpaper_bridge.cc

Issue 2264743002: cheets: implement cros side of WallpaperManagerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cheets: implement cros side of WallpaperManagerService. Created 4 years, 4 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
« no previous file with comments | « components/arc/wallpaper/arc_wallpaper_bridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/wallpaper/arc_wallpaper_bridge.cc
diff --git a/components/arc/wallpaper/arc_wallpaper_bridge.cc b/components/arc/wallpaper/arc_wallpaper_bridge.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2490d45070726462438021912a820183bfdf494a
--- /dev/null
+++ b/components/arc/wallpaper/arc_wallpaper_bridge.cc
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/arc/wallpaper/arc_wallpaper_bridge.h"
+
+#include <vector>
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "components/arc/arc_bridge_service.h"
+#include "components/arc/set_wallpaper_delegate.h"
+
+namespace arc {
+
+namespace {
+
+void HandleWallpaperResult(
+ const base::Callback<void(mojo::Array<uint8_t>)>& callback,
+ const std::vector<uint8_t>& image) {
+ callback.Run(std::move(image));
+}
+
+} // namespace
+
+ArcWallpaperBridge::ArcWallpaperBridge(ArcBridgeService* bridge_service,
+ SetWallpaperDelegate* delegate)
+ : ArcService(bridge_service),
+ wallpaper_delegate_(delegate),
+ binding_(this) {
+ arc_bridge_service()->wallpaper()->AddObserver(this);
+}
+
+ArcWallpaperBridge::~ArcWallpaperBridge() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->wallpaper()->RemoveObserver(this);
+}
+
+void ArcWallpaperBridge::OnInstanceReady() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ mojom::WallpaperInstance* wallpaper_instance =
+ arc_bridge_service()->wallpaper()->instance();
+ if (!wallpaper_instance) {
+ LOG(ERROR) << "OnWallpaperInstanceReady called, "
+ << "but no wallpaper instance found";
+ return;
+ }
+ wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
+}
+
+void ArcWallpaperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage());
+}
+
+void ArcWallpaperBridge::GetWallpaper(
+ const base::Callback<void(mojo::Array<uint8_t>)>& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ wallpaper_delegate_->GetWallpaper(
+ base::Bind(&HandleWallpaperResult, callback));
dcheng 2016/08/29 20:33:19 FWIW, mojo::Array and stuff are deprecated. If we
Muyuan 2016/08/30 01:02:33 Added a TODO in the source. I'll fix that in the f
+}
+
+} // namespace arc
« no previous file with comments | « components/arc/wallpaper/arc_wallpaper_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698