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

Unified Diff: components/arc/intent_helper/activity_icon_loader.cc

Issue 2337193005: Consolidate 4 GetIntentHelper functions (Closed)
Patch Set: Address comments2 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/intent_helper/activity_icon_loader.cc
diff --git a/components/arc/intent_helper/activity_icon_loader.cc b/components/arc/intent_helper/activity_icon_loader.cc
index b0046a482a537f6373ce703747327a15adcfa1d5..bf135a5d3d8454a734fd0b0893423157dd531ca1 100644
--- a/components/arc/intent_helper/activity_icon_loader.cc
+++ b/components/arc/intent_helper/activity_icon_loader.cc
@@ -28,30 +28,6 @@ const size_t kMaxIconSizeInPx = 200;
const int kMinInstanceVersion = 3; // see intent_helper.mojom
-mojom::IntentHelperInstance* GetIntentHelperInstance(
- ActivityIconLoader::GetResult* out_error_code) {
- DCHECK(out_error_code);
- ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
- if (!bridge_service) {
- VLOG(2) << "ARC bridge is not ready.";
- *out_error_code = ActivityIconLoader::GetResult::FAILED_ARC_NOT_SUPPORTED;
- return nullptr;
- }
- mojom::IntentHelperInstance* intent_helper_instance =
- bridge_service->intent_helper()->instance();
- if (!intent_helper_instance) {
- VLOG(2) << "ARC intent helper instance is not ready.";
- *out_error_code = ActivityIconLoader::GetResult::FAILED_ARC_NOT_READY;
- return nullptr;
- }
- if (bridge_service->intent_helper()->version() < kMinInstanceVersion) {
- VLOG(1) << "ARC intent helper instance is too old.";
- *out_error_code = ActivityIconLoader::GetResult::FAILED_ARC_NOT_SUPPORTED;
- return nullptr;
- }
- return intent_helper_instance;
-}
-
ui::ScaleFactor GetSupportedScaleFactor() {
std::vector<ui::ScaleFactor> scale_factors = ui::GetSupportedScaleFactors();
DCHECK(!scale_factors.empty());
@@ -112,13 +88,21 @@ ActivityIconLoader::GetResult ActivityIconLoader::GetActivityIcons(
return GetResult::SUCCEEDED_SYNC;
}
- GetResult error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
- mojom::IntentHelperInstance* instance = GetIntentHelperInstance(&error_code);
+ ArcIntentHelperBridge::GetResult error_code;
+ mojom::IntentHelperInstance* instance =
+ ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
+ kMinInstanceVersion, &error_code);
if (!instance) {
// The mojo channel is not yet ready (or not supported at all). Run the
// callback with |result| that could be empty.
cb.Run(std::move(result));
- return error_code;
+ switch (error_code) {
+ case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_READY:
+ return GetResult(GetResult::FAILED_ARC_NOT_READY);
+ case ArcIntentHelperBridge::GetResult::FAILED_ARC_NOT_SUPPORTED:
+ return GetResult(GetResult::FAILED_ARC_NOT_SUPPORTED);
+ }
+ NOTREACHED();
}
// Fetch icons from ARC.
« no previous file with comments | « components/arc/intent_helper/activity_icon_loader.h ('k') | components/arc/intent_helper/arc_intent_helper_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698