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/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. | 96 // Lazy initialization of IdentitySource. |
|
David Trainor- moved to gerrit
2016/08/30 20:46:29
Can this just call GetIdentitySource()->Connect()?
xingliu
2016/08/30 22:27:36
Done.
| |
| 97 if (!identity_source_) { | 97 if (!identity_source_) { |
| 98 identity_source_ = base::MakeUnique<IdentitySource>( | 98 CreateIdentitySource(); |
| 99 delegate_, | |
| 100 base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | |
| 101 base::Unretained(this))); | |
| 102 } | 99 } |
| 103 | 100 |
| 104 // Start Blimp authentication flow. The OAuth2 token will be used in | 101 // Start Blimp authentication flow. The OAuth2 token will be used in |
| 105 // assignment source. | 102 // assignment source. |
| 106 identity_source_->Connect(); | 103 identity_source_->Connect(); |
| 107 } | 104 } |
| 108 | 105 |
| 106 IdentitySource* BlimpClientContextImpl::GetIdentitySource() { | |
| 107 if (!identity_source_) { | |
| 108 CreateIdentitySource(); | |
| 109 } | |
| 110 return identity_source_.get(); | |
| 111 } | |
| 112 | |
| 109 void BlimpClientContextImpl::ConnectToAssignmentSource( | 113 void BlimpClientContextImpl::ConnectToAssignmentSource( |
| 110 const std::string& client_auth_token) { | 114 const std::string& client_auth_token) { |
| 111 if (!assignment_source_) { | 115 if (!assignment_source_) { |
| 112 assignment_source_.reset(new AssignmentSource( | 116 assignment_source_.reset(new AssignmentSource( |
| 113 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); | 117 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); |
| 114 } | 118 } |
| 115 | 119 |
| 116 VLOG(1) << "Trying to get assignment."; | 120 VLOG(1) << "Trying to get assignment."; |
| 117 assignment_source_->GetAssignment( | 121 assignment_source_->GetAssignment( |
| 118 client_auth_token, | 122 client_auth_token, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 162 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
| 159 ime_feature_.get())); | 163 ime_feature_.get())); |
| 160 navigation_feature_->set_outgoing_message_processor( | 164 navigation_feature_->set_outgoing_message_processor( |
| 161 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, | 165 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, |
| 162 navigation_feature_.get())); | 166 navigation_feature_.get())); |
| 163 tab_control_feature_->set_outgoing_message_processor( | 167 tab_control_feature_->set_outgoing_message_processor( |
| 164 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, | 168 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, |
| 165 tab_control_feature_.get())); | 169 tab_control_feature_.get())); |
| 166 } | 170 } |
| 167 | 171 |
| 172 void BlimpClientContextImpl::CreateIdentitySource() { | |
| 173 identity_source_ = base::MakeUnique<IdentitySource>( | |
| 174 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | |
| 175 base::Unretained(this))); | |
| 176 } | |
| 177 | |
| 168 } // namespace client | 178 } // namespace client |
| 169 } // namespace blimp | 179 } // namespace blimp |
| OLD | NEW |