| 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..5441be4a294e3c5753cd4598f7867829fe795fb8
|
| --- /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,
|
| + 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));
|
| +}
|
| +
|
| +} // namespace arc
|
|
|