Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "blimp/client/core/context/blimp_client_context_impl.h" | 5 #include "blimp/client/core/context/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 base::Unretained(net_components_.get()))); | 140 base::Unretained(net_components_.get()))); |
| 141 | 141 |
| 142 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); | 142 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); |
| 143 } | 143 } |
| 144 | 144 |
| 145 BlimpClientContextImpl::~BlimpClientContextImpl() { | 145 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 146 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 146 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| 147 connection_status_.RemoveObserver(this); | 147 connection_status_.RemoveObserver(this); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 150 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
|
Khushal
2016/11/03 00:13:35
This is being called with a null delegate from its
nyquist
2016/11/03 00:21:40
This makes sense to me.
xingliu
2016/11/03 00:33:31
Sorry I didn't notice in dtor it sets to nullptr.
Khushal
2016/11/03 00:50:48
I just looked at that class, and yes, it does look
xingliu
2016/11/03 01:45:37
Yeah, that's probably the right way to do that :)
| |
| 151 delegate_ = delegate; | 151 delegate_ = delegate; |
| 152 | |
| 153 // |assignment_fetcher_| needs services from BlimpClientContextDelegate, so | |
| 154 // it can't be created in the constructor. | |
| 155 DCHECK(delegate_); | |
| 156 assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>( | |
| 157 io_thread_task_runner_, file_thread_task_runner_, | |
| 158 delegate_->CreateIdentityProvider(), GetAssignerURL(), | |
| 159 base::Bind(&BlimpClientContextImpl::OnAssignmentReceived, | |
| 160 weak_factory_.GetWeakPtr()), | |
| 161 base::Bind(&BlimpClientContextDelegate::OnAuthenticationError, | |
| 162 base::Unretained(delegate_))); | |
| 152 } | 163 } |
| 153 | 164 |
| 154 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents( | 165 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents( |
| 155 gfx::NativeWindow window) { | 166 gfx::NativeWindow window) { |
| 156 std::unique_ptr<BlimpContents> blimp_contents = | 167 std::unique_ptr<BlimpContents> blimp_contents = |
| 157 blimp_contents_manager_->CreateBlimpContents(window); | 168 blimp_contents_manager_->CreateBlimpContents(window); |
| 158 if (blimp_contents) | 169 if (blimp_contents) |
| 159 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 170 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
| 160 return blimp_contents; | 171 return blimp_contents; |
| 161 } | 172 } |
| 162 | 173 |
| 163 void BlimpClientContextImpl::Connect() { | 174 void BlimpClientContextImpl::Connect() { |
| 164 if (!assignment_fetcher_) { | 175 DCHECK(assignment_fetcher_); |
| 165 assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>( | |
| 166 io_thread_task_runner_, file_thread_task_runner_, | |
| 167 delegate_->CreateIdentityProvider(), GetAssignerURL(), | |
| 168 base::Bind(&BlimpClientContextImpl::OnAssignmentReceived, | |
| 169 weak_factory_.GetWeakPtr()), | |
| 170 base::Bind(&BlimpClientContextDelegate::OnAuthenticationError, | |
| 171 base::Unretained(delegate_))); | |
| 172 } | |
| 173 assignment_fetcher_->Fetch(); | 176 assignment_fetcher_->Fetch(); |
| 174 } | 177 } |
| 175 | 178 |
| 176 void BlimpClientContextImpl::ConnectWithAssignment( | 179 void BlimpClientContextImpl::ConnectWithAssignment( |
| 177 const Assignment& assignment) { | 180 const Assignment& assignment) { |
| 178 io_thread_task_runner_->PostTask( | 181 io_thread_task_runner_->PostTask( |
| 179 FROM_HERE, | 182 FROM_HERE, |
| 180 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, | 183 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, |
| 181 base::Unretained(net_components_.get()), assignment)); | 184 base::Unretained(net_components_.get()), assignment)); |
| 182 } | 185 } |
| 183 | 186 |
| 184 std::unordered_map<std::string, std::string> | 187 std::unordered_map<std::string, std::string> |
| 185 BlimpClientContextImpl::CreateFeedbackData() { | 188 BlimpClientContextImpl::CreateFeedbackData() { |
| 186 return CreateBlimpFeedbackData(blimp_contents_manager_.get()); | 189 return CreateBlimpFeedbackData(blimp_contents_manager_.get()); |
| 187 } | 190 } |
| 188 | 191 |
| 189 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { | 192 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { |
| 193 DCHECK(assignment_fetcher_); | |
| 190 return assignment_fetcher_->GetIdentitySource(); | 194 return assignment_fetcher_->GetIdentitySource(); |
| 191 } | 195 } |
| 192 | 196 |
| 193 ConnectionStatus* BlimpClientContextImpl::GetConnectionStatus() { | 197 ConnectionStatus* BlimpClientContextImpl::GetConnectionStatus() { |
| 194 return &connection_status_; | 198 return &connection_status_; |
| 195 } | 199 } |
| 196 | 200 |
| 197 GURL BlimpClientContextImpl::GetAssignerURL() { | 201 GURL BlimpClientContextImpl::GetAssignerURL() { |
| 198 return GURL(kDefaultAssignerUrl); | 202 return GURL(kDefaultAssignerUrl); |
| 199 } | 203 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 if (result >= 0) { | 273 if (result >= 0) { |
| 270 delegate_->OnEngineDisconnected(result); | 274 delegate_->OnEngineDisconnected(result); |
| 271 } else { | 275 } else { |
| 272 delegate_->OnNetworkDisconnected(result); | 276 delegate_->OnNetworkDisconnected(result); |
| 273 } | 277 } |
| 274 } | 278 } |
| 275 } | 279 } |
| 276 | 280 |
| 277 } // namespace client | 281 } // namespace client |
| 278 } // namespace blimp | 282 } // namespace blimp |
| OLD | NEW |