Chromium Code Reviews| 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..e691af6b3c1129aa7af2b59072fff15e3716bb1a |
| --- /dev/null |
| +++ b/components/arc/wallpaper/arc_wallpaper_bridge.cc |
| @@ -0,0 +1,51 @@ |
| +// 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/threading/thread_checker.h" |
|
xiyuan
2016/08/19 23:04:07
This should be moved to header file since we decla
Muyuan
2016/08/22 22:25:00
Done.
|
| + |
| + |
| +namespace arc { |
| + |
| +ArcWallpaperBridge::ArcWallpaperBridge(ArcBridgeService* bridge_service, |
| + const |
| + std::shared_ptr<SetWallpaperDelegate>& |
|
xiyuan
2016/08/19 23:04:07
nit: The format looks wrong. Can you run "git cl f
Muyuan
2016/08/22 22:25:00
Done.
|
| + delegate) |
| + : ArcService(bridge_service), |
| + wallpaper_delegate_(delegate), |
| + binding_(this) { |
| + arc_bridge_service()->wallpaper()->AddObserver(this); |
| +} |
| + |
| +ArcWallpaperBridge::~ArcWallpaperBridge() { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
|
xiyuan
2016/08/19 23:04:07
#include "base/logging.h"
Muyuan
2016/08/22 22:25:00
Done.
|
| + arc_bridge_service()->wallpaper()->RemoveObserver(this); |
| +} |
| + |
| +void ArcWallpaperBridge::OnInstanceReady() { |
| + 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) { |
| + std::vector<uint8_t> image = wallpaper_delegate_->GetWallpaper(); |
| + callback.Run(std::move(image)); |
| +} |
| + |
| +} // namespace arc |