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

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: Fixed misplaced EXPORT directive 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
« no previous file with comments | « blimp/engine/browser/blimp_engine_session.h ('k') | blimp/net/blimp_connection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
40 #endif 41 #endif
41 42
42 namespace blimp { 43 namespace blimp {
43 namespace engine { 44 namespace engine {
44 namespace { 45 namespace {
45 46
46 const int kDummyTabId = 0; 47 const int kDummyTabId = 0;
47 const float kDefaultScaleFactor = 1.f; 48 const float kDefaultScaleFactor = 1.f;
48 const int kDefaultDisplayWidth = 800; 49 const int kDefaultDisplayWidth = 800;
49 const int kDefaultDisplayHeight = 600; 50 const int kDefaultDisplayHeight = 600;
50 const uint16_t kDefaultPortNumber = 25467; 51 const uint16_t kDefaultPort = 25467;
51 52
52 // Focus rules that support activating an child window. 53 // Focus rules that support activating an child window.
53 class FocusRulesImpl : public wm::BaseFocusRules { 54 class FocusRulesImpl : public wm::BaseFocusRules {
54 public: 55 public:
55 FocusRulesImpl() {} 56 FocusRulesImpl() {}
56 ~FocusRulesImpl() override {} 57 ~FocusRulesImpl() override {}
57 58
58 bool SupportsChildActivation(aura::Window* window) const override { 59 bool SupportsChildActivation(aura::Window* window) const override {
59 return true; 60 return true;
60 } 61 }
61 62
62 private: 63 private:
63 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); 64 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl);
64 }; 65 };
65 66
67 net::IPAddressNumber GetIPv4AnyAddress() {
68 net::IPAddressNumber output;
69 output.push_back(0);
70 output.push_back(0);
71 output.push_back(0);
72 output.push_back(0);
73 return output;
74 }
75
66 } // namespace 76 } // namespace
67 77
68 // This class's functions and destruction are all invoked on the IO thread by 78 // This class's functions and destruction are all invoked on the IO thread by
69 // the BlimpEngineSession. 79 // the BlimpEngineSession.
70 class BlimpNetworkComponents { 80 class EngineNetworkComponents {
71 public: 81 public:
72 explicit BlimpNetworkComponents(net::NetLog* net_log); 82 explicit EngineNetworkComponents(net::NetLog* net_log);
73 ~BlimpNetworkComponents(); 83 ~EngineNetworkComponents();
74 84
75 void Initialize(); 85 void Initialize();
76 86
77 private: 87 private:
78 net::NetLog* net_log_; 88 net::NetLog* net_log_;
79 scoped_ptr<BrowserConnectionHandler> connection_handler_; 89 scoped_ptr<BrowserConnectionHandler> connection_handler_;
80 scoped_ptr<EngineAuthenticationHandler> authentication_handler_; 90 scoped_ptr<EngineAuthenticationHandler> authentication_handler_;
81 scoped_ptr<EngineConnectionManager> connection_manager_; 91 scoped_ptr<EngineConnectionManager> connection_manager_;
82 92
83 DISALLOW_COPY_AND_ASSIGN(BlimpNetworkComponents); 93 DISALLOW_COPY_AND_ASSIGN(EngineNetworkComponents);
84 }; 94 };
85 95
86 BlimpNetworkComponents::BlimpNetworkComponents(net::NetLog* net_log) 96 EngineNetworkComponents::EngineNetworkComponents(net::NetLog* net_log)
87 : net_log_(net_log) {} 97 : net_log_(net_log) {}
88 98
89 BlimpNetworkComponents::~BlimpNetworkComponents() { 99 EngineNetworkComponents::~EngineNetworkComponents() {
90 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 100 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
91 } 101 }
92 102
93 void BlimpNetworkComponents::Initialize() { 103 void EngineNetworkComponents::Initialize() {
94 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 104 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
95 DCHECK(!connection_handler_); 105 DCHECK(!connection_handler_);
96 106
97 // Creates and connects net components. 107 // Creates and connects net components.
98 // A BlimpConnection flows from 108 // A BlimpConnection flows from
99 // connection_manager_ --> authentication_handler_ --> connection_handler_ 109 // connection_manager_ --> authentication_handler_ --> connection_handler_
100 connection_handler_.reset(new BrowserConnectionHandler); 110 connection_handler_.reset(new BrowserConnectionHandler);
101 authentication_handler_.reset( 111 authentication_handler_.reset(
102 new EngineAuthenticationHandler(connection_handler_.get())); 112 new EngineAuthenticationHandler(connection_handler_.get()));
103 connection_manager_.reset( 113 connection_manager_.reset(
104 new EngineConnectionManager(authentication_handler_.get())); 114 new EngineConnectionManager(authentication_handler_.get()));
105 115
106 // Adds BlimpTransports to connection_manager_. 116 // Adds BlimpTransports to connection_manager_.
107 net::IPAddressNumber local_ip_any; 117 net::IPEndPoint address(GetIPv4AnyAddress(), kDefaultPort);
108 bool success = net::ParseIPLiteralToNumber("0.0.0.0", &local_ip_any);
109 DCHECK(success);
110 net::IPEndPoint address(local_ip_any, kDefaultPortNumber);
111 connection_manager_->AddTransport( 118 connection_manager_->AddTransport(
112 make_scoped_ptr(new TCPEngineTransport(address, net_log_))); 119 make_scoped_ptr(new TCPEngineTransport(address, net_log_)));
113 } 120 }
114 121
115 BlimpEngineSession::BlimpEngineSession( 122 BlimpEngineSession::BlimpEngineSession(
116 scoped_ptr<BlimpBrowserContext> browser_context, 123 scoped_ptr<BlimpBrowserContext> browser_context,
117 net::NetLog* net_log) 124 net::NetLog* net_log)
118 : browser_context_(std::move(browser_context)), 125 : browser_context_(std::move(browser_context)),
119 screen_(new BlimpScreen), 126 screen_(new BlimpScreen),
120 net_components_(new BlimpNetworkComponents(net_log)) { 127 net_components_(new EngineNetworkComponents(net_log)) {
121 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor, 128 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor,
122 gfx::Size(kDefaultDisplayWidth, 129 gfx::Size(kDefaultDisplayWidth,
123 kDefaultDisplayHeight)); 130 kDefaultDisplayHeight));
124 render_widget_feature_.SetDelegate(kDummyTabId, this); 131 render_widget_feature_.SetDelegate(kDummyTabId, this);
125 } 132 }
126 133
127 BlimpEngineSession::~BlimpEngineSession() { 134 BlimpEngineSession::~BlimpEngineSession() {
128 render_widget_feature_.RemoveDelegate(kDummyTabId); 135 render_widget_feature_.RemoveDelegate(kDummyTabId);
129 136
130 // Safely delete network components on the IO thread. 137 // Safely delete network components on the IO thread.
(...skipping 26 matching lines...) Expand all
157 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 164 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
158 165
159 #if defined(USE_X11) 166 #if defined(USE_X11)
160 window_tree_host_->Show(); 167 window_tree_host_->Show();
161 #endif 168 #endif
162 169
163 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size())); 170 window_tree_host_->SetBounds(gfx::Rect(screen_->GetPrimaryDisplay().size()));
164 171
165 content::BrowserThread::PostTask( 172 content::BrowserThread::PostTask(
166 content::BrowserThread::IO, FROM_HERE, 173 content::BrowserThread::IO, FROM_HERE,
167 base::Bind(&BlimpNetworkComponents::Initialize, 174 base::Bind(&EngineNetworkComponents::Initialize,
168 base::Unretained(net_components_.get()))); 175 base::Unretained(net_components_.get())));
169 176
170 // Registers features. 177 // Register features' message senders and receivers.
171 // TODO(kmarshall) Refactor this using
172 // 1. Get outgoing message processors for blimp message types of a feature.
173 // 2. Create a feature with these outgoing message processors.
174 // 3. Register the feature as the incoming message processor for these
175 // blimp message types.
176 tab_control_message_sender_ = 178 tab_control_message_sender_ =
177 RegisterFeature(BlimpMessage::TAB_CONTROL, this); 179 RegisterFeature(BlimpMessage::TAB_CONTROL, this);
178 navigation_message_sender_ = RegisterFeature(BlimpMessage::NAVIGATION, this); 180 navigation_message_sender_ = RegisterFeature(BlimpMessage::NAVIGATION, this);
179
180 render_widget_feature_.set_render_widget_message_sender( 181 render_widget_feature_.set_render_widget_message_sender(
181 RegisterFeature(BlimpMessage::RENDER_WIDGET, &render_widget_feature_)); 182 RegisterFeature(BlimpMessage::RENDER_WIDGET, &render_widget_feature_));
182 render_widget_feature_.set_input_message_sender( 183 render_widget_feature_.set_input_message_sender(
183 RegisterFeature(BlimpMessage::INPUT, &render_widget_feature_)); 184 RegisterFeature(BlimpMessage::INPUT, &render_widget_feature_));
184 render_widget_feature_.set_compositor_message_sender( 185 render_widget_feature_.set_compositor_message_sender(
185 RegisterFeature(BlimpMessage::COMPOSITOR, &render_widget_feature_)); 186 RegisterFeature(BlimpMessage::COMPOSITOR, &render_widget_feature_));
186 } 187 }
187 188
188 scoped_ptr<BlimpMessageProcessor> BlimpEngineSession::RegisterFeature( 189 scoped_ptr<BlimpMessageProcessor> BlimpEngineSession::RegisterFeature(
189 BlimpMessage::Type type, 190 BlimpMessage::Type type,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 432
432 aura::Window* parent = window_tree_host_->window(); 433 aura::Window* parent = window_tree_host_->window();
433 aura::Window* content = web_contents_->GetNativeView(); 434 aura::Window* content = web_contents_->GetNativeView();
434 if (!parent->Contains(content)) 435 if (!parent->Contains(content))
435 parent->AddChild(content); 436 parent->AddChild(content);
436 content->Show(); 437 content->Show();
437 } 438 }
438 439
439 } // namespace engine 440 } // namespace engine
440 } // namespace blimp 441 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/browser/blimp_engine_session.h ('k') | blimp/net/blimp_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698