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

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: Fixes for nits. 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 identity_source_ = base::MakeUnique<IdentitySource>(
88 delegate_,
89 base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource,
90 base::Unretained(this)));
91 }
92
93 // Start Blimp authentication flow. The OAuth2 token will be used in
94 // assignment source.
95 identity_source_->Connect();
96 }
97
98 void BlimpClientContextImpl::ConnectToAssignmentSource(
99 const std::string& client_auth_token) {
85 if (!assignment_source_) { 100 if (!assignment_source_) {
86 assignment_source_.reset(new AssignmentSource( 101 assignment_source_.reset(new AssignmentSource(
87 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); 102 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_));
88 } 103 }
89 104
90 VLOG(1) << "Trying to get assignment."; 105 VLOG(1) << "Trying to get assignment.";
91 assignment_source_->GetAssignment( 106 assignment_source_->GetAssignment(
92 client_auth_token, 107 client_auth_token,
93 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment, 108 base::Bind(&BlimpClientContextImpl::ConnectWithAssignment,
94 weak_factory_.GetWeakPtr())); 109 weak_factory_.GetWeakPtr()));
(...skipping 22 matching lines...) Expand all
117 } 132 }
118 133
119 io_thread_task_runner_->PostTask( 134 io_thread_task_runner_->PostTask(
120 FROM_HERE, 135 FROM_HERE,
121 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 136 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
122 base::Unretained(net_components_.get()), assignment)); 137 base::Unretained(net_components_.get()), assignment));
123 } 138 }
124 139
125 } // namespace client 140 } // namespace client
126 } // namespace blimp 141 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/blimp_client_context_impl.h ('k') | blimp/client/core/dummy_blimp_client_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698