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

Side by Side Diff: blimp/client/session/blimp_client_session.cc

Issue 1687393002: Add assigner support to Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/session/blimp_client_session.h" 5 #include "blimp/client/session/blimp_client_session.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/thread_task_runner_handle.h"
13 #include "base/threading/sequenced_task_runner_handle.h" 14 #include "base/threading/sequenced_task_runner_handle.h"
14 #include "blimp/client/app/blimp_client_switches.h" 15 #include "blimp/client/app/blimp_client_switches.h"
15 #include "blimp/client/feature/navigation_feature.h" 16 #include "blimp/client/feature/navigation_feature.h"
16 #include "blimp/client/feature/render_widget_feature.h" 17 #include "blimp/client/feature/render_widget_feature.h"
17 #include "blimp/client/feature/tab_control_feature.h" 18 #include "blimp/client/feature/tab_control_feature.h"
18 #include "blimp/net/blimp_message_processor.h" 19 #include "blimp/net/blimp_message_processor.h"
19 #include "blimp/net/blimp_message_thread_pipe.h" 20 #include "blimp/net/blimp_message_thread_pipe.h"
20 #include "blimp/net/browser_connection_handler.h" 21 #include "blimp/net/browser_connection_handler.h"
21 #include "blimp/net/client_connection_manager.h" 22 #include "blimp/net/client_connection_manager.h"
22 #include "blimp/net/common.h" 23 #include "blimp/net/common.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // actual sender of the |outgoing_pipe|. 100 // actual sender of the |outgoing_pipe|.
100 scoped_ptr<BlimpMessageProcessor> outgoing_message_processor = 101 scoped_ptr<BlimpMessageProcessor> outgoing_message_processor =
101 browser_connection_handler_->RegisterFeature(type, incoming_proxy.get()); 102 browser_connection_handler_->RegisterFeature(type, incoming_proxy.get());
102 outgoing_pipe->set_target_processor(outgoing_message_processor.get()); 103 outgoing_pipe->set_target_processor(outgoing_message_processor.get());
103 104
104 incoming_proxies_.push_back(std::move(incoming_proxy)); 105 incoming_proxies_.push_back(std::move(incoming_proxy));
105 outgoing_pipes_.push_back(std::move(outgoing_pipe)); 106 outgoing_pipes_.push_back(std::move(outgoing_pipe));
106 outgoing_message_processors_.push_back(std::move(outgoing_message_processor)); 107 outgoing_message_processors_.push_back(std::move(outgoing_message_processor));
107 } 108 }
108 109
109 BlimpClientSession::BlimpClientSession( 110 BlimpClientSession::BlimpClientSession()
110 scoped_ptr<AssignmentSource> assignment_source) 111 : io_thread_("BlimpIOThread"),
111 : assignment_source_(std::move(assignment_source)),
112 io_thread_("BlimpIOThread"),
113 tab_control_feature_(new TabControlFeature), 112 tab_control_feature_(new TabControlFeature),
114 navigation_feature_(new NavigationFeature), 113 navigation_feature_(new NavigationFeature),
115 render_widget_feature_(new RenderWidgetFeature), 114 render_widget_feature_(new RenderWidgetFeature),
116 net_components_(new ClientNetworkComponents), 115 net_components_(new ClientNetworkComponents),
117 weak_factory_(this) { 116 weak_factory_(this) {
118 base::Thread::Options options; 117 base::Thread::Options options;
119 options.message_loop_type = base::MessageLoop::TYPE_IO; 118 options.message_loop_type = base::MessageLoop::TYPE_IO;
120 io_thread_.StartWithOptions(options); 119 io_thread_.StartWithOptions(options);
121 120
121 assignment_source_.reset(new AssignmentSource(
122 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner()));
123
122 // Register features' message senders and receivers. 124 // Register features' message senders and receivers.
123 tab_control_feature_->set_outgoing_message_processor( 125 tab_control_feature_->set_outgoing_message_processor(
124 RegisterFeature(BlimpMessage::TAB_CONTROL, tab_control_feature_.get())); 126 RegisterFeature(BlimpMessage::TAB_CONTROL, tab_control_feature_.get()));
125 navigation_feature_->set_outgoing_message_processor( 127 navigation_feature_->set_outgoing_message_processor(
126 RegisterFeature(BlimpMessage::NAVIGATION, navigation_feature_.get())); 128 RegisterFeature(BlimpMessage::NAVIGATION, navigation_feature_.get()));
127 render_widget_feature_->set_outgoing_input_message_processor( 129 render_widget_feature_->set_outgoing_input_message_processor(
128 RegisterFeature(BlimpMessage::INPUT, render_widget_feature_.get())); 130 RegisterFeature(BlimpMessage::INPUT, render_widget_feature_.get()));
129 render_widget_feature_->set_outgoing_compositor_message_processor( 131 render_widget_feature_->set_outgoing_compositor_message_processor(
130 RegisterFeature(BlimpMessage::COMPOSITOR, render_widget_feature_.get())); 132 RegisterFeature(BlimpMessage::COMPOSITOR, render_widget_feature_.get()));
131 133
132 // We don't expect to send any RenderWidget messages, so don't save the 134 // We don't expect to send any RenderWidget messages, so don't save the
133 // outgoing BlimpMessageProcessor in the RenderWidgetFeature. 135 // outgoing BlimpMessageProcessor in the RenderWidgetFeature.
134 RegisterFeature(BlimpMessage::RENDER_WIDGET, render_widget_feature_.get()); 136 RegisterFeature(BlimpMessage::RENDER_WIDGET, render_widget_feature_.get());
135 137
136 // Initialize must only be posted after the RegisterFeature calls have 138 // Initialize must only be posted after the RegisterFeature calls have
137 // completed. 139 // completed.
138 io_thread_.task_runner()->PostTask( 140 io_thread_.task_runner()->PostTask(
139 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, 141 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize,
140 base::Unretained(net_components_.get()))); 142 base::Unretained(net_components_.get())));
141 } 143 }
142 144
143 BlimpClientSession::~BlimpClientSession() { 145 BlimpClientSession::~BlimpClientSession() {
144 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release()); 146 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release());
145 } 147 }
146 148
147 void BlimpClientSession::Connect() { 149 void BlimpClientSession::Connect(const std::string& token) {
148 assignment_source_->GetAssignment(base::Bind( 150 assignment_source_->GetAssignment(
149 &BlimpClientSession::ConnectWithAssignment, weak_factory_.GetWeakPtr())); 151 token, base::Bind(&BlimpClientSession::ConnectWithAssignment,
152 weak_factory_.GetWeakPtr()));
150 } 153 }
151 154
152 void BlimpClientSession::ConnectWithAssignment(const Assignment& assignment) { 155 void BlimpClientSession::ConnectWithAssignment(AssignmentSourceResult result,
156 const Assignment& assignment) {
157 if (result != ASSIGNMENT_SOURCE_RESULT_OKAY) {
158 DVLOG(1) << "Assignment request failed: " << result;
159 return;
Kevin M 2016/02/12 19:45:27 Should the subclasses be filtering out the erroneo
David Trainor- moved to gerrit 2016/02/17 21:09:48 Yeah good point. I changed this to always call an
160 }
161
153 io_thread_.task_runner()->PostTask( 162 io_thread_.task_runner()->PostTask(
154 FROM_HERE, 163 FROM_HERE,
155 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 164 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
156 base::Unretained(net_components_.get()), assignment)); 165 base::Unretained(net_components_.get()), assignment));
157 } 166 }
158 167
159 scoped_ptr<BlimpMessageProcessor> BlimpClientSession::RegisterFeature( 168 scoped_ptr<BlimpMessageProcessor> BlimpClientSession::RegisterFeature(
160 BlimpMessage::Type type, 169 BlimpMessage::Type type,
161 BlimpMessageProcessor* incoming_processor) { 170 BlimpMessageProcessor* incoming_processor) {
162 // Creates an outgoing pipe and a proxy for forwarding messages 171 // Creates an outgoing pipe and a proxy for forwarding messages
(...skipping 29 matching lines...) Expand all
192 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { 201 NavigationFeature* BlimpClientSession::GetNavigationFeature() const {
193 return navigation_feature_.get(); 202 return navigation_feature_.get();
194 } 203 }
195 204
196 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { 205 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const {
197 return render_widget_feature_.get(); 206 return render_widget_feature_.get();
198 } 207 }
199 208
200 } // namespace client 209 } // namespace client
201 } // namespace blimp 210 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698