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

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

Issue 1933053003: Used oneof in blimp_message.proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/session/blimp_engine_session.h" 5 #include "blimp/engine/session/blimp_engine_session.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void BlimpEngineSession::RegisterFeatures() { 272 void BlimpEngineSession::RegisterFeatures() {
273 thread_pipe_manager_.reset(new ThreadPipeManager( 273 thread_pipe_manager_.reset(new ThreadPipeManager(
274 content::BrowserThread::GetMessageLoopProxyForThread( 274 content::BrowserThread::GetMessageLoopProxyForThread(
275 content::BrowserThread::IO), 275 content::BrowserThread::IO),
276 content::BrowserThread::GetMessageLoopProxyForThread( 276 content::BrowserThread::GetMessageLoopProxyForThread(
277 content::BrowserThread::UI), 277 content::BrowserThread::UI),
278 net_components_->GetBrowserConnectionHandler())); 278 net_components_->GetBrowserConnectionHandler()));
279 279
280 // Register features' message senders and receivers. 280 // Register features' message senders and receivers.
281 tab_control_message_sender_ = 281 tab_control_message_sender_ =
282 thread_pipe_manager_->RegisterFeature(BlimpMessage::TAB_CONTROL, this); 282 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, this);
283 navigation_message_sender_ = 283 navigation_message_sender_ =
284 thread_pipe_manager_->RegisterFeature(BlimpMessage::NAVIGATION, this); 284 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, this);
285 render_widget_feature_.set_render_widget_message_sender( 285 render_widget_feature_.set_render_widget_message_sender(
286 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET, 286 thread_pipe_manager_->RegisterFeature(BlimpMessage::kRenderWidget,
287 &render_widget_feature_)); 287 &render_widget_feature_));
288 render_widget_feature_.set_input_message_sender( 288 render_widget_feature_.set_input_message_sender(
289 thread_pipe_manager_->RegisterFeature(BlimpMessage::INPUT, 289 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput,
290 &render_widget_feature_)); 290 &render_widget_feature_));
291 render_widget_feature_.set_compositor_message_sender( 291 render_widget_feature_.set_compositor_message_sender(
292 thread_pipe_manager_->RegisterFeature(BlimpMessage::COMPOSITOR, 292 thread_pipe_manager_->RegisterFeature(BlimpMessage::kCompositor,
293 &render_widget_feature_)); 293 &render_widget_feature_));
294 render_widget_feature_.set_ime_message_sender( 294 render_widget_feature_.set_ime_message_sender(
295 thread_pipe_manager_->RegisterFeature(BlimpMessage::IME, 295 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme,
296 &render_widget_feature_)); 296 &render_widget_feature_));
297 297
298 // The Settings feature does not need an outgoing message processor, since we 298 // The Settings feature does not need an outgoing message processor, since we
299 // don't send any messages to the client right now. 299 // don't send any messages to the client right now.
300 thread_pipe_manager_->RegisterFeature(BlimpMessage::SETTINGS, 300 thread_pipe_manager_->RegisterFeature(BlimpMessage::kSettings,
301 &settings_feature_); 301 &settings_feature_);
302 } 302 }
303 303
304 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) { 304 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) {
305 DVLOG(1) << "Create tab " << target_tab_id; 305 DVLOG(1) << "Create tab " << target_tab_id;
306 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). 306 // TODO(haibinlu): Support more than one active WebContents (crbug/547231).
307 if (web_contents_) { 307 if (web_contents_) {
308 DLOG(WARNING) << "Tab " << target_tab_id << " already existed"; 308 DLOG(WARNING) << "Tab " << target_tab_id << " already existed";
309 return false; 309 return false;
310 } 310 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(), 433 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(),
434 window_tree_host_->GetInputMethod()->GetTextInputClient()); 434 window_tree_host_->GetInputMethod()->GetTextInputClient());
435 } 435 }
436 436
437 void BlimpEngineSession::ProcessMessage( 437 void BlimpEngineSession::ProcessMessage(
438 std::unique_ptr<BlimpMessage> message, 438 std::unique_ptr<BlimpMessage> message,
439 const net::CompletionCallback& callback) { 439 const net::CompletionCallback& callback) {
440 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId", 440 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId",
441 message->target_tab_id()); 441 message->target_tab_id());
442 DCHECK(!callback.is_null()); 442 DCHECK(!callback.is_null());
443 DCHECK(message->type() == BlimpMessage::TAB_CONTROL || 443 DCHECK(message->has_tab_control() || message->has_navigation());
444 message->type() == BlimpMessage::NAVIGATION);
445 444
446 net::Error result = net::OK; 445 net::Error result = net::OK;
447 if (message->type() == BlimpMessage::TAB_CONTROL) { 446 if (message->has_tab_control()) {
Kevin M 2016/05/02 17:47:48 Check the case instead
shaktisahu 2016/05/16 20:19:02 I added it in the DCHECK above
448 switch (message->tab_control().type()) { 447 switch (message->tab_control().type()) {
449 case TabControlMessage::CREATE_TAB: 448 case TabControlMessage::CREATE_TAB:
450 if (!CreateWebContents(message->target_tab_id())) 449 if (!CreateWebContents(message->target_tab_id()))
451 result = net::ERR_FAILED; 450 result = net::ERR_FAILED;
452 break; 451 break;
453 case TabControlMessage::CLOSE_TAB: 452 case TabControlMessage::CLOSE_TAB:
454 CloseWebContents(message->target_tab_id()); 453 CloseWebContents(message->target_tab_id());
455 case TabControlMessage::SIZE: 454 case TabControlMessage::SIZE:
456 HandleResize(message->tab_control().size().device_pixel_ratio(), 455 HandleResize(message->tab_control().size().device_pixel_ratio(),
457 gfx::Size(message->tab_control().size().width(), 456 gfx::Size(message->tab_control().size().width(),
458 message->tab_control().size().height())); 457 message->tab_control().size().height()));
459 break; 458 break;
460 default: 459 default:
461 NOTIMPLEMENTED(); 460 NOTIMPLEMENTED();
462 result = net::ERR_NOT_IMPLEMENTED; 461 result = net::ERR_NOT_IMPLEMENTED;
463 } 462 }
464 } else if (message->type() == BlimpMessage::NAVIGATION && web_contents_) { 463 } else if (message->has_navigation() && web_contents_) {
Kevin M 2016/05/02 17:47:48 ditto
shaktisahu 2016/05/16 20:19:02 Same as above.
465 switch (message->navigation().type()) { 464 switch (message->navigation().type()) {
466 case NavigationMessage::LOAD_URL: 465 case NavigationMessage::LOAD_URL:
467 LoadUrl(message->target_tab_id(), 466 LoadUrl(message->target_tab_id(),
468 GURL(message->navigation().load_url().url())); 467 GURL(message->navigation().load_url().url()));
469 break; 468 break;
470 case NavigationMessage::GO_BACK: 469 case NavigationMessage::GO_BACK:
471 GoBack(message->target_tab_id()); 470 GoBack(message->target_tab_id());
472 break; 471 break;
473 case NavigationMessage::GO_FORWARD: 472 case NavigationMessage::GO_FORWARD:
474 GoForward(message->target_tab_id()); 473 GoForward(message->target_tab_id());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 633
635 aura::Window* parent = window_tree_host_->window(); 634 aura::Window* parent = window_tree_host_->window();
636 aura::Window* content = web_contents_->GetNativeView(); 635 aura::Window* content = web_contents_->GetNativeView();
637 if (!parent->Contains(content)) 636 if (!parent->Contains(content))
638 parent->AddChild(content); 637 parent->AddChild(content);
639 content->Show(); 638 content->Show();
640 } 639 }
641 640
642 } // namespace engine 641 } // namespace engine
643 } // namespace blimp 642 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698