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

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
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 std::vector<uint8_t> image) {
21 callback.Run(std::move(image));
22 }
23 }
xiyuan 2016/08/22 22:49:41 nit: insert an empty line before and add "// names
Muyuan 2016/08/22 23:48:19 Done.
Shuhei Takahashi 2016/08/23 09:34:22 Could you upload a new patch please?
Muyuan 2016/08/23 19:45:49 Done.
24
25 ArcWallpaperBridge::ArcWallpaperBridge(
26 ArcBridgeService* bridge_service,
27 const std::shared_ptr<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 mojom::WallpaperInstance* wallpaper_instance =
Shuhei Takahashi 2016/08/23 09:34:22 Please call DCHECK(thread_checker_.CalledOnValidTh
Muyuan 2016/08/23 19:45:49 Done.
41 arc_bridge_service()->wallpaper()->instance();
42 if (!wallpaper_instance) {
43 LOG(ERROR) << "OnWallpaperInstanceReady called, "
44 << "but no wallpaper instance found";
45 return;
46 }
47 wallpaper_instance->Init(binding_.CreateInterfacePtrAndBind());
48 }
49
50 void ArcWallpaperBridge::SetWallpaper(mojo::Array<uint8_t> jpeg_data) {
51 DCHECK(thread_checker_.CalledOnValidThread());
52 wallpaper_delegate_->SetWallpaper(jpeg_data.PassStorage());
53 }
54
55 void ArcWallpaperBridge::GetWallpaper(
56 const base::Callback<void(mojo::Array<uint8_t>)>& callback) {
57 DCHECK(thread_checker_.CalledOnValidThread());
58 wallpaper_delegate_->GetWallpaper(
59 base::Bind(&HandleWallpaperResult, callback));
60 }
61
62 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698