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

Side by Side Diff: blimp/engine/browser/blimp_engine_session.cc

Issue 1551583003: Implementation and fixes for Blimp client/engine E2E communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dtrainor-linux-cl1528243002
Patch Set: Addressed haibin's feedback, made an ObserverList for ConnectionErrorObserver Created 4 years, 11 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/engine/browser/blimp_engine_session.h" 5 #include "blimp/engine/browser/blimp_engine_session.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "blimp/common/create_blimp_message.h" 8 #include "blimp/common/create_blimp_message.h"
9 #include "blimp/common/proto/tab_control.pb.h" 9 #include "blimp/common/proto/tab_control.pb.h"
10 #include "blimp/engine/browser/blimp_browser_context.h" 10 #include "blimp/engine/browser/blimp_browser_context.h"
11 #include "blimp/engine/ui/blimp_layout_manager.h" 11 #include "blimp/engine/ui/blimp_layout_manager.h"
12 #include "blimp/engine/ui/blimp_screen.h" 12 #include "blimp/engine/ui/blimp_screen.h"
13 #include "blimp/engine/ui/blimp_ui_context_factory.h" 13 #include "blimp/engine/ui/blimp_ui_context_factory.h"
14 #include "blimp/net/blimp_connection.h" 14 #include "blimp/net/blimp_connection.h"
15 #include "blimp/net/blimp_message_multiplexer.h" 15 #include "blimp/net/blimp_message_multiplexer.h"
16 #include "blimp/net/browser_connection_handler.h" 16 #include "blimp/net/browser_connection_handler.h"
17 #include "blimp/net/common.h"
17 #include "blimp/net/engine_authentication_handler.h" 18 #include "blimp/net/engine_authentication_handler.h"
18 #include "blimp/net/engine_connection_manager.h" 19 #include "blimp/net/engine_connection_manager.h"
19 #include "blimp/net/null_blimp_message_processor.h" 20 #include "blimp/net/null_blimp_message_processor.h"
20 #include "blimp/net/tcp_engine_transport.h" 21 #include "blimp/net/tcp_engine_transport.h"
21 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h" 25 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/render_widget_host.h" 27 #include "content/public/browser/render_widget_host.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 61 }
61 62
62 private: 63 private:
63 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); 64 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl);
64 }; 65 };
65 66
66 } // namespace 67 } // namespace
67 68
68 // This class's functions and destruction are all invoked on the IO thread by 69 // This class's functions and destruction are all invoked on the IO thread by
69 // the BlimpEngineSession. 70 // the BlimpEngineSession.
70 class BlimpNetworkComponents { 71 class EngineNetworkComponents {
71 public: 72 public:
72 explicit BlimpNetworkComponents(net::NetLog* net_log); 73 explicit EngineNetworkComponents(net::NetLog* net_log);
73 ~BlimpNetworkComponents(); 74 ~EngineNetworkComponents();
74 75
75 void Initialize(); 76 void Initialize();
76 77
77 private: 78 private:
78 net::NetLog* net_log_; 79 net::NetLog* net_log_;
79 scoped_ptr<BrowserConnectionHandler> connection_handler_; 80 scoped_ptr<BrowserConnectionHandler> connection_handler_;
80 scoped_ptr<EngineAuthenticationHandler> authentication_handler_; 81 scoped_ptr<EngineAuthenticationHandler> authentication_handler_;
81 scoped_ptr<EngineConnectionManager> connection_manager_; 82 scoped_ptr<EngineConnectionManager> connection_manager_;
82 83
83 DISALLOW_COPY_AND_ASSIGN(BlimpNetworkComponents); 84 DISALLOW_COPY_AND_ASSIGN(EngineNetworkComponents);
84 }; 85 };
85 86
86 BlimpNetworkComponents::BlimpNetworkComponents(net::NetLog* net_log) 87 EngineNetworkComponents::EngineNetworkComponents(net::NetLog* net_log)
87 : net_log_(net_log) {} 88 : net_log_(net_log) {}
88 89
89 BlimpNetworkComponents::~BlimpNetworkComponents() { 90 EngineNetworkComponents::~EngineNetworkComponents() {
90 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 91 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
91 } 92 }
92 93
93 void BlimpNetworkComponents::Initialize() { 94 void EngineNetworkComponents::Initialize() {
94 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 95 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
95 DCHECK(!connection_handler_); 96 DCHECK(!connection_handler_);
96 97
97 // Creates and connects net components. 98 // Creates and connects net components.
98 // A BlimpConnection flows from 99 // A BlimpConnection flows from
99 // connection_manager_ --> authentication_handler_ --> connection_handler_ 100 // connection_manager_ --> authentication_handler_ --> connection_handler_
100 connection_handler_.reset(new BrowserConnectionHandler); 101 connection_handler_.reset(new BrowserConnectionHandler);
101 authentication_handler_.reset( 102 authentication_handler_.reset(
102 new EngineAuthenticationHandler(connection_handler_.get())); 103 new EngineAuthenticationHandler(connection_handler_.get()));
103 connection_manager_.reset( 104 connection_manager_.reset(
104 new EngineConnectionManager(authentication_handler_.get())); 105 new EngineConnectionManager(authentication_handler_.get()));
105 106
106 // Adds BlimpTransports to connection_manager_. 107 // Adds BlimpTransports to connection_manager_.
107 net::IPAddressNumber local_ip_any; 108 net::IPAddressNumber local_ip_any;
108 bool success = net::ParseIPLiteralToNumber("0.0.0.0", &local_ip_any); 109 bool success = net::ParseIPLiteralToNumber("0.0.0.0", &local_ip_any);
109 DCHECK(success); 110 DCHECK(success);
110 net::IPEndPoint address(local_ip_any, kDefaultPortNumber); 111 net::IPEndPoint address(local_ip_any, kDefaultPortNumber);
111 connection_manager_->AddTransport( 112 connection_manager_->AddTransport(
112 make_scoped_ptr(new TCPEngineTransport(address, net_log_))); 113 make_scoped_ptr(new TCPEngineTransport(address, net_log_)));
113 } 114 }
114 115
115 BlimpEngineSession::BlimpEngineSession( 116 BlimpEngineSession::BlimpEngineSession(
116 scoped_ptr<BlimpBrowserContext> browser_context, 117 scoped_ptr<BlimpBrowserContext> browser_context,
117 net::NetLog* net_log) 118 net::NetLog* net_log)
118 : browser_context_(std::move(browser_context)), 119 : browser_context_(std::move(browser_context)),
119 screen_(new BlimpScreen), 120 screen_(new BlimpScreen),
120 net_components_(new BlimpNetworkComponents(net_log)) { 121 net_components_(new EngineNetworkComponents(net_log)) {
121 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor, 122 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor,
122 gfx::Size(kDefaultDisplayWidth, 123 gfx::Size(kDefaultDisplayWidth,
123 kDefaultDisplayHeight)); 124 kDefaultDisplayHeight));
124 render_widget_feature_.SetDelegate(kDummyTabId, this); 125 render_widget_feature_.SetDelegate(kDummyTabId, this);
125 } 126 }
126 127
127 BlimpEngineSession::~BlimpEngineSession() { 128 BlimpEngineSession::~BlimpEngineSession() {
128 render_widget_feature_.RemoveDelegate(kDummyTabId); 129 render_widget_feature_.RemoveDelegate(kDummyTabId);
129 130
130 // Safely delete network components on the IO thread. 131 // Safely delete network components on the IO thread.
(...skipping 26 matching lines...) Expand all
157 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 158 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
158 159
159 #if defined(USE_X11) 160 #if defined(USE_X11)
160 window_tree_host_->Show(); 161 window_tree_host_->Show();
161 #endif 162 #endif
162 163
163 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size())); 164 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size()));
164 165
165 content::BrowserThread::PostTask( 166 content::BrowserThread::PostTask(
166 content::BrowserThread::IO, FROM_HERE, 167 content::BrowserThread::IO, FROM_HERE,
167 base::Bind(&BlimpNetworkComponents::Initialize, 168 base::Bind(&EngineNetworkComponents::Initialize,
168 base::Unretained(net_components_.get()))); 169 base::Unretained(net_components_.get())));
169 170
170 // Registers features. 171 // Registers features.
171 // TODO(kmarshall) Refactor this using
172 // 1. Get outgoing message processors for blimp message types of a feature. 172 // 1. Get outgoing message processors for blimp message types of a feature.
haibinlu 2016/01/04 19:45:45 remove the comment here since TODO is removed.
Kevin M 2016/01/04 20:42:12 Done.
173 // 2. Create a feature with these outgoing message processors. 173 // 2. Create a feature with these outgoing message processors.
174 // 3. Register the feature as the incoming message processor for these 174 // 3. Register the feature as the incoming message processor for these
175 // blimp message types. 175 // blimp message types.
176 tab_control_message_sender_ = 176 tab_control_message_sender_ =
177 RegisterFeature(BlimpMessage::TAB_CONTROL, this); 177 RegisterFeature(BlimpMessage::TAB_CONTROL, this);
178 navigation_message_sender_ = RegisterFeature(BlimpMessage::NAVIGATION, this); 178 navigation_message_sender_ = RegisterFeature(BlimpMessage::NAVIGATION, this);
179 179
180 render_widget_feature_.set_render_widget_message_sender( 180 render_widget_feature_.set_render_widget_message_sender(
181 RegisterFeature(BlimpMessage::RENDER_WIDGET, &render_widget_feature_)); 181 RegisterFeature(BlimpMessage::RENDER_WIDGET, &render_widget_feature_));
182 render_widget_feature_.set_input_message_sender( 182 render_widget_feature_.set_input_message_sender(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 aura::Window* parent = window_tree_host_->window(); 432 aura::Window* parent = window_tree_host_->window();
433 aura::Window* content = web_contents_->GetNativeView(); 433 aura::Window* content = web_contents_->GetNativeView();
434 if (!parent->Contains(content)) 434 if (!parent->Contains(content))
435 parent->AddChild(content); 435 parent->AddChild(content);
436 content->Show(); 436 content->Show();
437 } 437 }
438 438
439 } // namespace engine 439 } // namespace engine
440 } // namespace blimp 440 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698