Skip to content

Commit

Permalink
personalization: remove unused ambient backend call
Browse files Browse the repository at this point in the history
We don't need to fetch settings preview anymore.

BUG=None
TEST=Build and check everything works ok

Change-Id: Ifcaab2a856d2619d4349c9d87cd35e93cd967a3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4265271
Commit-Queue: Jerry Liu <pzliu@google.com>
Reviewed-by: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107077}
  • Loading branch information
lpzjerry authored and Chromium LUCI CQ committed Feb 18, 2023
1 parent 50a91bb commit 05f34df
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 104 deletions.
60 changes: 0 additions & 60 deletions ash/ambient/backdrop/ambient_backend_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,6 @@ void AmbientBackendControllerImpl::UpdateSettings(
weak_factory_.GetWeakPtr(), settings, std::move(callback)));
}

void AmbientBackendControllerImpl::FetchSettingPreview(
const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback callback) {
Shell::Get()->ambient_controller()->RequestAccessToken(
base::BindOnce(&AmbientBackendControllerImpl::FetchSettingPreviewInternal,
weak_factory_.GetWeakPtr(), album_id, setting_id,
preview_width, preview_height, std::move(callback)));
}

void AmbientBackendControllerImpl::FetchPersonalAlbums(
int banner_width,
int banner_height,
Expand Down Expand Up @@ -628,54 +616,6 @@ void AmbientBackendControllerImpl::OnUpdateSettings(
std::move(callback).Run(success);
}

void AmbientBackendControllerImpl::FetchSettingPreviewInternal(
const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback callback,
const std::string& gaia_id,
const std::string& access_token) {
if (gaia_id.empty() || access_token.empty()) {
DVLOG(2) << "Failed to fetch access token";
// Returns an empty instance to indicate the failure.
std::move(callback).Run(/*preview_urls=*/{});
return;
}

BackdropClientConfig::Request request =
backdrop_client_config_.CreateFetchSettingPreviewRequest(
gaia_id, access_token, album_id, setting_id, preview_width,
preview_height);
std::unique_ptr<network::ResourceRequest> resource_request =
CreateResourceRequest(request);
auto backdrop_url_loader = std::make_unique<BackdropURLLoader>();
auto* loader_ptr = backdrop_url_loader.get();
loader_ptr->Start(
std::move(resource_request), /*request_body=*/absl::nullopt,
kAmbientBackendControllerNetworkTag,
base::BindOnce(&AmbientBackendControllerImpl::OnSettingPreviewFetched,
weak_factory_.GetWeakPtr(), std::move(callback),
std::move(backdrop_url_loader)));
}

void AmbientBackendControllerImpl::OnSettingPreviewFetched(
OnSettingPreviewFetchedCallback callback,
std::unique_ptr<BackdropURLLoader> backdrop_url_loader,
std::unique_ptr<std::string> response) {
DCHECK(backdrop_url_loader);

// Parse the |SettingPreviewResponse| out from the response string.
// Note that the |preview_urls| can be empty if the parsing has failed.
std::vector<std::string> parsed_response =
BackdropClientConfig::ParseSettingPreviewResponse(*response);
std::vector<GURL> preview_urls;
for (const std::string& preivew_url : parsed_response) {
preview_urls.emplace_back(preivew_url);
}
std::move(callback).Run(std::move(preview_urls));
}

void AmbientBackendControllerImpl::FetchPersonalAlbumsInternal(
int banner_width,
int banner_height,
Expand Down
18 changes: 0 additions & 18 deletions ash/ambient/backdrop/ambient_backend_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class AmbientBackendControllerImpl : public AmbientBackendController {
void GetSettings(GetSettingsCallback callback) override;
void UpdateSettings(const AmbientSettings& settings,
UpdateSettingsCallback callback) override;
void FetchSettingPreview(const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback callback) override;
void FetchPersonalAlbums(int banner_width,
int banner_height,
int num_albums,
Expand Down Expand Up @@ -95,19 +90,6 @@ class AmbientBackendControllerImpl : public AmbientBackendController {
std::unique_ptr<BackdropURLLoader> backdrop_url_loader,
std::unique_ptr<std::string> response);

void FetchSettingPreviewInternal(const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback callback,
const std::string& gaia_id,
const std::string& access_token);

void OnSettingPreviewFetched(
OnSettingPreviewFetchedCallback callback,
std::unique_ptr<BackdropURLLoader> backdrop_url_loader,
std::unique_ptr<std::string> response);

void FetchPersonalAlbumsInternal(int banner_width,
int banner_height,
int num_albums,
Expand Down
9 changes: 0 additions & 9 deletions ash/public/cpp/ambient/ambient_backend_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class ASH_PUBLIC_EXPORT AmbientBackendController {
using GetSettingsCallback =
base::OnceCallback<void(const absl::optional<AmbientSettings>& settings)>;
using UpdateSettingsCallback = base::OnceCallback<void(bool success)>;
using OnSettingPreviewFetchedCallback =
base::OnceCallback<void(const std::vector<GURL>& preview_urls)>;
using OnPersonalAlbumsFetchedCallback =
base::OnceCallback<void(PersonalAlbums)>;
// TODO(wutao): Make |settings| move only.
Expand Down Expand Up @@ -141,13 +139,6 @@ class ASH_PUBLIC_EXPORT AmbientBackendController {
virtual void UpdateSettings(const AmbientSettings& settings,
UpdateSettingsCallback callback) = 0;

// Fetch preview images for live album.
virtual void FetchSettingPreview(const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback) = 0;

virtual void FetchPersonalAlbums(int banner_width,
int banner_height,
int num_albums,
Expand Down
12 changes: 0 additions & 12 deletions ash/public/cpp/ambient/fake_ambient_backend_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,6 @@ void FakeAmbientBackendControllerImpl::UpdateSettings(
pending_update_callback_ = std::move(callback);
}

void FakeAmbientBackendControllerImpl::FetchSettingPreview(
const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback callback) {
std::vector<GURL> urls = {GURL(kFakeUrl)};
// Pretend to respond asynchronously.
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), urls));
}

void FakeAmbientBackendControllerImpl::FetchPersonalAlbums(
int banner_width,
int banner_height,
Expand Down
5 changes: 0 additions & 5 deletions ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class ASH_PUBLIC_EXPORT FakeAmbientBackendControllerImpl
void GetSettings(GetSettingsCallback callback) override;
void UpdateSettings(const AmbientSettings& settings,
UpdateSettingsCallback callback) override;
void FetchSettingPreview(const std::string& album_id,
int setting_id,
int preview_width,
int preview_height,
OnSettingPreviewFetchedCallback) override;
void FetchPersonalAlbums(int banner_width,
int banner_height,
int num_albums,
Expand Down

0 comments on commit 05f34df

Please sign in to comment.