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

Unified Diff: blimp/client/core/context/blimp_client_context_impl.cc

Issue 2470913005: Fix the blimp settings crash. (Closed)
Patch Set: Created 4 years, 1 month 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: 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..b912edc8138c8133a7d9b6a775518b9dd92e49b7 100644
--- a/blimp/client/core/context/blimp_client_context_impl.cc
+++ b/blimp/client/core/context/blimp_client_context_impl.cc
@@ -161,15 +161,9 @@ 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_)));
- }
+ if (!assignment_fetcher_)
+ CreateAssignmentFetcher();
+
assignment_fetcher_->Fetch();
}
@@ -187,6 +181,9 @@ BlimpClientContextImpl::CreateFeedbackData() {
}
IdentitySource* BlimpClientContextImpl::GetIdentitySource() {
+ if (!assignment_fetcher_)
+ CreateAssignmentFetcher();
+
return assignment_fetcher_->GetIdentitySource();
}
@@ -253,6 +250,22 @@ void BlimpClientContextImpl::DropConnection() {
FROM_HERE, base::Bind(&DropConnectionOnIOThread, net_components_.get()));
}
+void BlimpClientContextImpl::CreateAssignmentFetcher() {
+ if (assignment_fetcher_)
Khushal 2016/11/02 23:45:45 nit: Why do the if check at the call sites if you'
+ return;
+
+ // |assignment_fetcher_| needs services from BlimpClientContextDelegate, so
+ // it can't be created in the constructor.
+ DCHECK(delegate_);
+ assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>(
Khushal 2016/11/02 21:29:56 Can we create this in SetDelegate instead then? Ra
xingliu 2016/11/02 23:26:52 @nyquist, I think do it in SetDelegate makes sense
Khushal 2016/11/02 23:45:45 Definitely can't do without a |delegate_|, you nee
xingliu 2016/11/03 00:08:04 Yeah, agree. Put it into SetDelegate. Since the de
+ 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_)));
+}
+
void BlimpClientContextImpl::OnImageDecodeError() {
// Currently we just drop the connection on image decoding error.
DropConnection();

Powered by Google App Engine
This is Rietveld 408576698