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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 82 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
83 std::unique_ptr<BlimpContents> blimp_contents = | 83 std::unique_ptr<BlimpContents> blimp_contents = |
84 blimp_contents_manager_->CreateBlimpContents(); | 84 blimp_contents_manager_->CreateBlimpContents(); |
85 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 85 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
86 return blimp_contents; | 86 return blimp_contents; |
87 } | 87 } |
88 | 88 |
89 void BlimpClientContextImpl::Connect() { | 89 void BlimpClientContextImpl::Connect() { |
90 // Lazy initialization of IdentitySource. | 90 // Lazy initialization of IdentitySource. |
91 if (!identity_source_) { | 91 if (!identity_source_) { |
92 identity_source_ = base::MakeUnique<IdentitySource>( | 92 CreateIdentitySource(); |
93 delegate_, | |
94 base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | |
95 base::Unretained(this))); | |
96 } | 93 } |
97 | 94 |
98 // Start Blimp authentication flow. The OAuth2 token will be used in | 95 // Start Blimp authentication flow. The OAuth2 token will be used in |
99 // assignment source. | 96 // assignment source. |
100 identity_source_->Connect(); | 97 identity_source_->Connect(); |
101 } | 98 } |
102 | 99 |
103 void BlimpClientContextImpl::ConnectToAssignmentSource( | 100 void BlimpClientContextImpl::ConnectToAssignmentSource( |
104 const std::string& client_auth_token) { | 101 const std::string& client_auth_token) { |
105 if (!assignment_source_) { | 102 if (!assignment_source_) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 base::Unretained(net_components_.get()), assignment)); | 143 base::Unretained(net_components_.get()), assignment)); |
147 } | 144 } |
148 | 145 |
149 void BlimpClientContextImpl::RegisterFeatures() { | 146 void BlimpClientContextImpl::RegisterFeatures() { |
150 // Register features' message senders and receivers. | 147 // Register features' message senders and receivers. |
151 tab_control_feature_->set_outgoing_message_processor( | 148 tab_control_feature_->set_outgoing_message_processor( |
152 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, | 149 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, |
153 tab_control_feature_.get())); | 150 tab_control_feature_.get())); |
154 } | 151 } |
155 | 152 |
| 153 void BlimpClientContextImpl::CreateIdentitySource() { |
| 154 identity_source_ = base::MakeUnique<IdentitySource>( |
| 155 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, |
| 156 base::Unretained(this))); |
| 157 } |
| 158 |
156 } // namespace client | 159 } // namespace client |
157 } // namespace blimp | 160 } // namespace blimp |
OLD | NEW |