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

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

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: review 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/arc_intent_helper_bridge.cc
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc
index 74d7446cda0c0f69c96d52d81431a8af4f2b77d9..254b7f4121d37a42675de91077c96317122af58d 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc
@@ -48,8 +48,11 @@ ArcIntentHelperBridge::~ArcIntentHelperBridge() {
void ArcIntentHelperBridge::OnInstanceReady() {
DCHECK(thread_checker_.CalledOnValidThread());
ash::Shell::GetInstance()->set_link_handler_model_factory(this);
- arc_bridge_service()->intent_helper()->instance()->Init(
- binding_.CreateInterfacePtrAndBind());
+ auto* instance =
+ arc_bridge_service()->intent_helper()->GetInstanceForMethod("Init");
+ if (!instance)
+ return;
+ instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcIntentHelperBridge::OnInstanceClosed() {
@@ -121,7 +124,8 @@ ArcIntentHelperBridge::FilterOutIntentHelper(
// static
mojom::IntentHelperInstance*
ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
- int min_instance_version,
+ const std::string& method_name_for_logging,
+ uint32_t min_instance_version,
GetResult* out_error_code) {
ArcBridgeService* bridge_service = ArcBridgeService::Get();
if (!bridge_service) {
@@ -136,29 +140,30 @@ ArcIntentHelperBridge::GetIntentHelperInstanceWithErrorCode(
}
return nullptr;
}
- mojom::IntentHelperInstance* intent_helper_instance =
- bridge_service->intent_helper()->instance();
- if (!intent_helper_instance) {
+
+ if (!bridge_service->intent_helper()->HasInstance()) {
VLOG(2) << "ARC intent helper instance is not ready.";
if (out_error_code)
*out_error_code = GetResult::FAILED_ARC_NOT_READY;
return nullptr;
}
- const int version = bridge_service->intent_helper()->version();
- if (version < min_instance_version) {
- VLOG(1) << "ARC intent helper instance is too old. required: "
- << min_instance_version << ", actual: " << version;
+
+ auto* instance = bridge_service->intent_helper()->GetInstanceForMethod(
+ method_name_for_logging, min_instance_version);
+ if (!instance) {
if (out_error_code)
*out_error_code = GetResult::FAILED_ARC_NOT_SUPPORTED;
return nullptr;
}
- return intent_helper_instance;
+ return instance;
}
// static
mojom::IntentHelperInstance* ArcIntentHelperBridge::GetIntentHelperInstance(
- int min_instance_version) {
- return GetIntentHelperInstanceWithErrorCode(min_instance_version, nullptr);
+ const std::string& method_name_for_logging,
+ uint32_t min_instance_version) {
+ return GetIntentHelperInstanceWithErrorCode(method_name_for_logging,
+ min_instance_version, nullptr);
}
void ArcIntentHelperBridge::OnIntentFiltersUpdated(

Powered by Google App Engine
This is Rietveld 408576698