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

Side by Side Diff: blimp/client/core/blimp_client_context_impl.cc

Issue 2204223005: Blimp OAuth2 token retreival on application start up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests compiling. Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 delegate_ = delegate; 74 delegate_ = delegate;
75 } 75 }
76 76
77 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { 77 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() {
78 std::unique_ptr<BlimpContents> blimp_contents = 78 std::unique_ptr<BlimpContents> blimp_contents =
79 blimp_contents_manager_->CreateBlimpContents(); 79 blimp_contents_manager_->CreateBlimpContents();
80 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); 80 delegate_->AttachBlimpContentsHelpers(blimp_contents.get());
81 return blimp_contents; 81 return blimp_contents;
82 } 82 }
83 83
84 void BlimpClientContextImpl::Connect(const std::string& client_auth_token) { 84 void BlimpClientContextImpl::Connect() {
85 // Lazy initialization of IdentitySource.
86 if (!identity_source_) {
87 DCHECK(delegate_);
88 identity_source_ =
89 base::MakeUnique<IdentitySource>(delegate_->CreateIdentityProvider());
90 identity_source_->SetDelegate(delegate_);
91 }
92
93 // Start Blimp authentication flow. After fetching the OAuth2 token, use it in
94 // assignment source.
95 identity_source_->Connect(
96 base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource,
97 base::Unretained(this)));
98 }
99
100 void BlimpClientContextImpl::ConnectToAssignmentSource(
101 const std::string& client_auth_token) {
85 if (!assignment_source_) { 102 if (!assignment_source_) {
86 assignment_source_.reset(new AssignmentSource( 103 assignment_source_.reset(new AssignmentSource(
87 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); 104 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_));
88 } 105 }
89 106
90 VLOG(1) << "Trying to get assignment."; 107 VLOG(1) << "Trying to get assignment.";
91 assignment_source_->GetAssignment( 108 assignment_source_->GetAssignment(
92 client_auth_token, 109 client_auth_token,
93 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment, 110 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment,
94 weak_factory_.GetWeakPtr())); 111 weak_factory_.GetWeakPtr()));
(...skipping 22 matching lines...) Expand all
117 } 134 }
118 135
119 io_thread_task_runner_->PostTask( 136 io_thread_task_runner_->PostTask(
120 FROM_HERE, 137 FROM_HERE,
121 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 138 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
122 base::Unretained(net_components_.get()), assignment)); 139 base::Unretained(net_components_.get()), assignment));
123 } 140 }
124 141
125 } // namespace client 142 } // namespace client
126 } // namespace blimp 143 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698