| OLD | NEW |
| 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_sessi
on.h" | 5 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_sessi
on.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "content/public/common/service_registry.h" | 9 #include "content/public/common/service_registry.h" |
| 10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 : binding_(this), | 22 : binding_(this), |
| 23 params_(params), | 23 params_(params), |
| 24 weak_factory_(this) { | 24 weak_factory_(this) { |
| 25 DCHECK(params_.render_frame); | 25 DCHECK(params_.render_frame); |
| 26 params.render_frame->GetServiceRegistry()->ConnectToRemoteService( | 26 params.render_frame->GetServiceRegistry()->ConnectToRemoteService( |
| 27 mojo::GetProxy(&service_)); | 27 mojo::GetProxy(&service_)); |
| 28 service_.set_connection_error_handler(base::Bind( | 28 service_.set_connection_error_handler(base::Bind( |
| 29 &WiFiDisplaySession::OnConnectionError, | 29 &WiFiDisplaySession::OnConnectionError, |
| 30 weak_factory_.GetWeakPtr())); | 30 weak_factory_.GetWeakPtr())); |
| 31 | 31 |
| 32 WiFiDisplaySessionServiceClientPtr client_ptr; | 32 service_->SetClient(binding_.CreateInterfacePtrAndBind()); |
| 33 binding_.Bind(GetProxy(&client_ptr)); | |
| 34 binding_.set_connection_error_handler(base::Bind( | 33 binding_.set_connection_error_handler(base::Bind( |
| 35 &WiFiDisplaySession::OnConnectionError, | 34 &WiFiDisplaySession::OnConnectionError, |
| 36 weak_factory_.GetWeakPtr())); | 35 weak_factory_.GetWeakPtr())); |
| 37 DCHECK(client_ptr); | |
| 38 service_->SetClient(std::move(client_ptr)); | |
| 39 } | 36 } |
| 40 | 37 |
| 41 WiFiDisplaySession::~WiFiDisplaySession() { | 38 WiFiDisplaySession::~WiFiDisplaySession() { |
| 42 } | 39 } |
| 43 | 40 |
| 44 void WiFiDisplaySession::Start() { | 41 void WiFiDisplaySession::Start() { |
| 45 DCHECK(state_ == DisplaySourceSession::Idle); | 42 DCHECK(state_ == DisplaySourceSession::Idle); |
| 46 service_->Connect(params_.sink_id, params_.auth_method, params_.auth_data); | 43 service_->Connect(params_.sink_id, params_.auth_method, params_.auth_data); |
| 47 state_ = DisplaySourceSession::Establishing; | 44 state_ = DisplaySourceSession::Establishing; |
| 48 } | 45 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 if (state_ == DisplaySourceSession::Established || | 106 if (state_ == DisplaySourceSession::Established || |
| 110 state_ == DisplaySourceSession::Terminating) { | 107 state_ == DisplaySourceSession::Terminating) { |
| 111 // We must explicitly notify the session termination as it will never | 108 // We must explicitly notify the session termination as it will never |
| 112 // arrive from browser process (IPC is broken). | 109 // arrive from browser process (IPC is broken). |
| 113 if (!terminated_callback_.is_null()) | 110 if (!terminated_callback_.is_null()) |
| 114 terminated_callback_.Run(params_.sink_id); | 111 terminated_callback_.Run(params_.sink_id); |
| 115 } | 112 } |
| 116 } | 113 } |
| 117 | 114 |
| 118 } // namespace extensions | 115 } // namespace extensions |
| OLD | NEW |