Skip to content

Commit

Permalink
Use enum switch cases in ImeService::InitializeConnectionFactory().
Browse files Browse the repository at this point in the history
... instead of having an "else" catch-all fallback case for the 2nd
enum case which should actually be on-par counterpart with the 1st.

This helps demonstrate better the comms between IME service container
here and different kinds of IME impls: "rule-based" (embedded in the
container) and "shared lib in Associated Mojo mode".

__SIMPLE_REVIEW__

Bug: 1287417
Change-Id: Ia1046088cbdb52aecfc094f93313853184022e67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3558657
Reviewed-by: Keith Lee <keithlee@chromium.org>
Commit-Queue: Bao-Duy Tran <tranbaoduy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987385}
  • Loading branch information
Bao-Duy Tran authored and Chromium LUCI CQ committed Mar 31, 2022
1 parent 494b9bf commit cab2885
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions ash/services/ime/ime_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,24 @@ void ImeService::InitializeConnectionFactory(
system_engine_.reset();
rule_based_engine_.reset();

if (connection_target == mojom::ConnectionTarget::kImeService) {
connection_factory_ =
std::make_unique<ConnectionFactory>(std::move(connection_factory));
std::move(callback).Run(/*success=*/true);
} else {
auto system_engine = std::make_unique<SystemEngine>(
this, ime_decoder_->MaybeLoadThenReturnEntryPoints());
bool bound =
system_engine->BindConnectionFactory(std::move(connection_factory));
system_engine_ = std::move(system_engine);
std::move(callback).Run(bound);
switch (connection_target) {
case mojom::ConnectionTarget::kImeService: {
connection_factory_ =
std::make_unique<ConnectionFactory>(std::move(connection_factory));
std::move(callback).Run(/*success=*/true);
break;
}
case mojom::ConnectionTarget::kDecoder: {
auto system_engine = std::make_unique<SystemEngine>(
this, ime_decoder_->MaybeLoadThenReturnEntryPoints());
bool bound =
system_engine->BindConnectionFactory(std::move(connection_factory));
system_engine_ = std::move(system_engine);
std::move(callback).Run(bound);
break;
}
default:
break;
}
}

Expand Down

0 comments on commit cab2885

Please sign in to comment.