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..e22d0cf704ea42e8de694e1c7ee864590ee42914 |
| --- /dev/null |
| +++ b/components/arc/wallpaper/arc_wallpaper_bridge.cc |
| @@ -0,0 +1,62 @@ |
| +// 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)); |
| +} |
| +} |
|
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.
|
| + |
| +ArcWallpaperBridge::ArcWallpaperBridge( |
| + ArcBridgeService* bridge_service, |
| + const std::shared_ptr<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() { |
| + 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.
|
| + 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 |