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

Side by Side 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, 3 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 unified diff | Download patch
« no previous file with comments | « components/arc/wallpaper/arc_wallpaper_bridge.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/arc/wallpaper/arc_wallpaper_bridge.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/logging.h"
11 #include "components/arc/arc_bridge_service.h"
12 #include "components/arc/set_wallpaper_delegate.h"
13
14 namespace arc {
15
16 namespace {
17
18 void HandleWallpaperResult(
19 const base::Callback<void(mojo::Array<uint8_t>)>& callback,
20 const std::vector<uint8_t>& image) {
21 callback.Run(std::move(image));
22 }
23
24 } // namespace
25
26 ArcWallpaperBridge::ArcWallpaperBridge(ArcBridgeService* bridge_service,
27 SetWallpaperDelegate* delegate)
28 : ArcService(bridge_service),
29 wallpaper_delegate_(delegate),
30 binding_(this) {
31 arc_bridge_service()->wallpaper()->AddObserver(this);
32 }
33
34 ArcWallpaperBridge::~ArcWallpaperBridge() {
35 DCHECK(thread_checker_.CalledOnValidThread());
36 arc_bridge_service()->wallpaper()->RemoveObserver(this);
37 }
38
39 void ArcWallpaperBridge::OnInstanceReady() {
40 DCHECK(thread_checker_.CalledOnValidThread());
41 mojom::WallpaperInstance* wallpaper_instance =
42 arc_bridge_service()->wallpaper()->instance();
43 if (!wallpaper_instance) {
44 LOG(ERROR) << "OnWallpaperInstanceReady called, "
45 << "but no wallpaper instance found";
46 return;
47 }
48 wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
49 }
50
51 void ArcWallpaperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
52 DCHECK(thread_checker_.CalledOnValidThread());
53 wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage());
54 }
55
56 void ArcWallpaperBridge::GetWallpaper(
57 const base::Callback<void(mojo::Array<uint8_t>)>& callback) {
58 DCHECK(thread_checker_.CalledOnValidThread());
59 wallpaper_delegate_->GetWallpaper(
60 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
61 }
62
63 } // namespace arc
OLDNEW
« 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