0

Fix the blimp settings crash.

The assignment fetcher is not initialized when the settings jni bridge
needs it, which causes the crash.

To reproduce the bug, we need to clear adb_chrome_public_command_line.
Run:
build/android/adb_chrome_public_command_line ""

Intialization detail:
Since assignment fetcher and identity source both need identity
provider, which is a service created from BlimpClientContextDelegate,
they can't be created in the ctor of BlimpClientContextImpl.

With another CL: https://codereview.chromium.org/2471733002/
We should be able to run local server with client_engine_integration
script, but currently there might be other bugs that local client still
can't receive messages from local engine.

BUG=661322

Review-Url: https://codereview.chromium.org/2470913005
Cr-Commit-Position: refs/heads/master@{#429618}
This commit is contained in:
xingliu
2016-11-03 09:44:53 -07:00
committed by Commit bot
parent aa50c29e24
commit 6a658f84fc
2 changed files with 16 additions and 9 deletions

@ -148,7 +148,20 @@ BlimpClientContextImpl::~BlimpClientContextImpl() {
}
void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) {
DCHECK(!delegate_ || !delegate);
delegate_ = delegate;
// TODO(xingliu): Pass the IdentityProvider needed by |assignment_fetcher_|
// in the constructor, see crbug/661848.
if (delegate_) {
assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>(
io_thread_task_runner_, file_thread_task_runner_,
delegate_->CreateIdentityProvider(), GetAssignerURL(),
base::Bind(&BlimpClientContextImpl::OnAssignmentReceived,
weak_factory_.GetWeakPtr()),
base::Bind(&BlimpClientContextDelegate::OnAuthenticationError,
base::Unretained(delegate_)));
}
}
std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents(
@ -161,15 +174,7 @@ std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents(
}
void BlimpClientContextImpl::Connect() {
if (!assignment_fetcher_) {
assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>(
io_thread_task_runner_, file_thread_task_runner_,
delegate_->CreateIdentityProvider(), GetAssignerURL(),
base::Bind(&BlimpClientContextImpl::OnAssignmentReceived,
weak_factory_.GetWeakPtr()),
base::Bind(&BlimpClientContextDelegate::OnAuthenticationError,
base::Unretained(delegate_)));
}
DCHECK(assignment_fetcher_);
assignment_fetcher_->Fetch();
}
@ -187,6 +192,7 @@ BlimpClientContextImpl::CreateFeedbackData() {
}
IdentitySource* BlimpClientContextImpl::GetIdentitySource() {
DCHECK(assignment_fetcher_);
return assignment_fetcher_->GetIdentitySource();
}

@ -66,6 +66,7 @@ class BlimpClientContext : public KeyedService {
static void ApplyBlimpSwitches(CommandLinePrefStore* store);
// The delegate provides all the required functionality from the embedder.
// The context must be initialized with a |delegate| before it can be used.
virtual void SetDelegate(BlimpClientContextDelegate* delegate) = 0;
// Creates a new BlimpContents that will be shown in |window|.