Chromium Code Reviews| Index: blimp/client/session/blimp_client_session.cc |
| diff --git a/blimp/client/session/blimp_client_session.cc b/blimp/client/session/blimp_client_session.cc |
| index 5b75a823bcd20db99095917cf5d495c902af898c..5e47a261ed22dbe880fbb2f71712303a92939c9e 100644 |
| --- a/blimp/client/session/blimp_client_session.cc |
| +++ b/blimp/client/session/blimp_client_session.cc |
| @@ -18,9 +18,12 @@ |
| #include "blimp/client/feature/render_widget_feature.h" |
| #include "blimp/client/feature/settings_feature.h" |
| #include "blimp/client/feature/tab_control_feature.h" |
| +#include "blimp/common/blob_cache/in_memory_blob_cache.h" |
| #include "blimp/net/blimp_connection.h" |
| #include "blimp/net/blimp_message_processor.h" |
| #include "blimp/net/blimp_message_thread_pipe.h" |
| +#include "blimp/net/blob_channel/blob_channel_receiver.h" |
| +#include "blimp/net/blob_channel/helium_blob_receiver_delegate.h" |
| #include "blimp/net/browser_connection_handler.h" |
| #include "blimp/net/client_connection_manager.h" |
| #include "blimp/net/common.h" |
| @@ -86,6 +89,8 @@ class ClientNetworkComponents : public ConnectionHandler, |
| BrowserConnectionHandler* GetBrowserConnectionHandler(); |
| + void DropCurrentConnection(); |
| + |
| private: |
| // ConnectionHandler implementation. |
| void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; |
| @@ -152,6 +157,10 @@ ClientNetworkComponents::GetBrowserConnectionHandler() { |
| return connection_handler_.get(); |
| } |
| +void ClientNetworkComponents::DropCurrentConnection() { |
| + connection_handler_->DropCurrentConnection(); |
| +} |
| + |
| void ClientNetworkComponents::HandleConnection( |
| std::unique_ptr<BlimpConnection> connection) { |
| VLOG(1) << "Connection established."; |
| @@ -167,6 +176,10 @@ void ClientNetworkComponents::OnConnectionError(int result) { |
| BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint) |
| : io_thread_("BlimpIOThread"), |
| + blob_delegate_(new HeliumBlobReceiverDelegate), |
| + blob_receiver_( |
| + BlobChannelReceiver::Create(base::WrapUnique(new InMemoryBlobCache), |
| + base::WrapUnique(blob_delegate_))), |
| tab_control_feature_(new TabControlFeature), |
| navigation_feature_(new NavigationFeature), |
| ime_feature_(new ImeFeature), |
| @@ -185,8 +198,18 @@ BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint) |
| assignment_source_.reset(new AssignmentSource( |
| assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner())); |
| + std::unique_ptr<HeliumBlobReceiverDelegate> blob_delegate( |
|
nyquist
2016/06/03 18:30:44
You seem to do these operations in the constructor
Kevin M
2016/06/06 17:43:38
Uh, whoops.
Done.
|
| + new HeliumBlobReceiverDelegate); |
| + blob_delegate_ = blob_delegate.get(); |
| + blob_receiver_ = BlobChannelReceiver::Create( |
| + base::WrapUnique(new InMemoryBlobCache), std::move(blob_delegate)); |
| + |
| RegisterFeatures(); |
| + ClientImageSerializationProcessor::GetInstance()->set_blob_receiver( |
| + blob_receiver_.get()); |
| + ClientImageSerializationProcessor::GetInstance()->set_error_delegate(this); |
| + |
| // Initialize must only be posted after the RegisterFeature calls have |
| // completed. |
| io_thread_.task_runner()->PostTask( |
| @@ -247,6 +270,8 @@ void BlimpClientSession::RegisterFeatures() { |
| settings_feature_->set_outgoing_message_processor( |
| thread_pipe_manager_->RegisterFeature(BlimpMessage::kSettings, |
| settings_feature_.get())); |
| + thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel, |
| + blob_delegate_); |
| // Client will not send send any RenderWidget messages, so don't save the |
| // outgoing BlimpMessageProcessor in the RenderWidgetFeature. |
| @@ -266,6 +291,12 @@ void BlimpClientSession::OnConnected() {} |
| void BlimpClientSession::OnDisconnected(int result) {} |
| +void BlimpClientSession::OnImageDecodeError() { |
| + io_thread_.task_runner()->PostTask( |
| + FROM_HERE, base::Bind(&ClientNetworkComponents::DropCurrentConnection, |
| + base::Unretained(net_components_.get()))); |
| +} |
| + |
| TabControlFeature* BlimpClientSession::GetTabControlFeature() const { |
| return tab_control_feature_.get(); |
| } |