| 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/blimp_client_context_impl.h" | 5 #include "blimp/client/core/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/sequenced_task_runner_handle.h" | 10 #include "base/threading/sequenced_task_runner_handle.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 88 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
| 89 std::unique_ptr<BlimpContents> blimp_contents = | 89 std::unique_ptr<BlimpContents> blimp_contents = |
| 90 blimp_contents_manager_->CreateBlimpContents(); | 90 blimp_contents_manager_->CreateBlimpContents(); |
| 91 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 91 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
| 92 return blimp_contents; | 92 return blimp_contents; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void BlimpClientContextImpl::Connect() { | 95 void BlimpClientContextImpl::Connect() { |
| 96 // Lazy initialization of IdentitySource. | |
| 97 if (!identity_source_) { | |
| 98 identity_source_ = base::MakeUnique<IdentitySource>( | |
| 99 delegate_, | |
| 100 base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | |
| 101 base::Unretained(this))); | |
| 102 } | |
| 103 | |
| 104 // Start Blimp authentication flow. The OAuth2 token will be used in | 96 // Start Blimp authentication flow. The OAuth2 token will be used in |
| 105 // assignment source. | 97 // assignment source. |
| 106 identity_source_->Connect(); | 98 GetIdentitySource()->Connect(); |
| 99 } |
| 100 |
| 101 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { |
| 102 if (!identity_source_) { |
| 103 CreateIdentitySource(); |
| 104 } |
| 105 return identity_source_.get(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void BlimpClientContextImpl::ConnectToAssignmentSource( | 108 void BlimpClientContextImpl::ConnectToAssignmentSource( |
| 110 const std::string& client_auth_token) { | 109 const std::string& client_auth_token) { |
| 111 if (!assignment_source_) { | 110 if (!assignment_source_) { |
| 112 assignment_source_.reset(new AssignmentSource( | 111 assignment_source_.reset(new AssignmentSource( |
| 113 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); | 112 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); |
| 114 } | 113 } |
| 115 | 114 |
| 116 VLOG(1) << "Trying to get assignment."; | 115 VLOG(1) << "Trying to get assignment."; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 157 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
| 159 ime_feature_.get())); | 158 ime_feature_.get())); |
| 160 navigation_feature_->set_outgoing_message_processor( | 159 navigation_feature_->set_outgoing_message_processor( |
| 161 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, | 160 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, |
| 162 navigation_feature_.get())); | 161 navigation_feature_.get())); |
| 163 tab_control_feature_->set_outgoing_message_processor( | 162 tab_control_feature_->set_outgoing_message_processor( |
| 164 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, | 163 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, |
| 165 tab_control_feature_.get())); | 164 tab_control_feature_.get())); |
| 166 } | 165 } |
| 167 | 166 |
| 167 void BlimpClientContextImpl::CreateIdentitySource() { |
| 168 identity_source_ = base::MakeUnique<IdentitySource>( |
| 169 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, |
| 170 base::Unretained(this))); |
| 171 } |
| 172 |
| 168 } // namespace client | 173 } // namespace client |
| 169 } // namespace blimp | 174 } // namespace blimp |
| OLD | NEW |