Index: blimp/client/core/context/blimp_client_context_impl.cc |
diff --git a/blimp/client/core/context/blimp_client_context_impl.cc b/blimp/client/core/context/blimp_client_context_impl.cc |
index 81769e53483afa6bf70bf0211f742a2be050e0bc..7277f1ab6521bbcc13cd7e4189d3f7cfadf3c126 100644 |
--- a/blimp/client/core/context/blimp_client_context_impl.cc |
+++ b/blimp/client/core/context/blimp_client_context_impl.cc |
@@ -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(); |
} |