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 "blimp/client/session/blimp_client_session.h" | 5 #include "blimp/client/session/blimp_client_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "base/task_runner_util.h" |
16 #include "base/threading/sequenced_task_runner_handle.h" | 17 #include "base/threading/sequenced_task_runner_handle.h" |
17 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "blimp/client/core/blimp_client_switches.h" | 20 #include "blimp/client/core/blimp_client_switches.h" |
20 #include "blimp/client/core/contents/ime_feature.h" | 21 #include "blimp/client/core/contents/ime_feature.h" |
21 #include "blimp/client/core/contents/navigation_feature.h" | 22 #include "blimp/client/core/contents/navigation_feature.h" |
22 #include "blimp/client/core/contents/tab_control_feature.h" | 23 #include "blimp/client/core/contents/tab_control_feature.h" |
23 #include "blimp/client/core/geolocation/geolocation_feature.h" | 24 #include "blimp/client/core/geolocation/geolocation_feature.h" |
24 #include "blimp/client/core/render_widget/render_widget_feature.h" | 25 #include "blimp/client/core/render_widget/render_widget_feature.h" |
25 #include "blimp/client/core/session/client_network_components.h" | 26 #include "blimp/client/core/session/client_network_components.h" |
26 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 27 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
27 #include "blimp/client/core/settings/settings_feature.h" | 28 #include "blimp/client/core/settings/settings_feature.h" |
28 #include "blimp/common/blob_cache/in_memory_blob_cache.h" | 29 #include "blimp/common/blob_cache/in_memory_blob_cache.h" |
29 #include "blimp/net/blimp_message_thread_pipe.h" | 30 #include "blimp/net/blimp_message_thread_pipe.h" |
30 #include "blimp/net/blimp_stats.h" | 31 #include "blimp/net/blimp_stats.h" |
31 #include "blimp/net/blob_channel/blob_channel_receiver.h" | 32 #include "blimp/net/blob_channel/blob_channel_receiver.h" |
32 #include "blimp/net/blob_channel/helium_blob_receiver_delegate.h" | 33 #include "blimp/net/blob_channel/helium_blob_receiver_delegate.h" |
33 #include "blimp/net/thread_pipe_manager.h" | 34 #include "blimp/net/thread_pipe_manager.h" |
34 #include "device/geolocation/geolocation_delegate.h" | 35 #include "device/geolocation/geolocation_delegate.h" |
35 #include "device/geolocation/location_arbitrator.h" | 36 #include "device/geolocation/location_arbitrator.h" |
36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
37 | 38 |
38 namespace blimp { | 39 namespace blimp { |
39 namespace client { | 40 namespace client { |
| 41 namespace { |
| 42 |
| 43 void DropConnectionOnIOThread(ClientNetworkComponents* net_components) { |
| 44 net_components->GetBrowserConnectionHandler()->DropCurrentConnection(); |
| 45 } |
| 46 |
| 47 } // namespace |
40 | 48 |
41 BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint) | 49 BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint) |
42 : io_thread_("BlimpIOThread"), | 50 : io_thread_("BlimpIOThread"), |
43 geolocation_feature_(base::MakeUnique<GeolocationFeature>( | 51 geolocation_feature_(base::MakeUnique<GeolocationFeature>( |
44 base::MakeUnique<device::LocationArbitrator>( | 52 base::MakeUnique<device::LocationArbitrator>( |
45 base::MakeUnique<device::GeolocationDelegate>()))), | 53 base::MakeUnique<device::GeolocationDelegate>()))), |
46 tab_control_feature_(new TabControlFeature), | 54 tab_control_feature_(new TabControlFeature), |
47 navigation_feature_(new NavigationFeature), | 55 navigation_feature_(new NavigationFeature), |
48 ime_feature_(new ImeFeature), | 56 ime_feature_(new ImeFeature), |
49 render_widget_feature_(new RenderWidgetFeature), | 57 render_widget_feature_(new RenderWidgetFeature), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 150 |
143 ime_feature_->set_outgoing_message_processor( | 151 ime_feature_->set_outgoing_message_processor( |
144 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 152 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
145 ime_feature_.get())); | 153 ime_feature_.get())); |
146 | 154 |
147 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 155 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
148 switches::kDownloadWholeDocument)) | 156 switches::kDownloadWholeDocument)) |
149 settings_feature_->SetRecordWholeDocument(true); | 157 settings_feature_->SetRecordWholeDocument(true); |
150 } | 158 } |
151 | 159 |
| 160 void BlimpClientSession::DropConnection() { |
| 161 io_thread_.task_runner()->PostTask( |
| 162 FROM_HERE, base::Bind(&DropConnectionOnIOThread, net_components_.get())); |
| 163 } |
| 164 |
152 void BlimpClientSession::OnConnected() {} | 165 void BlimpClientSession::OnConnected() {} |
153 | 166 |
154 void BlimpClientSession::OnDisconnected(int result) {} | 167 void BlimpClientSession::OnDisconnected(int result) {} |
155 | 168 |
156 void BlimpClientSession::OnImageDecodeError() { | 169 void BlimpClientSession::OnImageDecodeError() { |
157 io_thread_.task_runner()->PostTask( | 170 DropConnection(); |
158 FROM_HERE, | |
159 base::Bind( | |
160 &BrowserConnectionHandler::DropCurrentConnection, | |
161 base::Unretained(net_components_->GetBrowserConnectionHandler()))); | |
162 } | 171 } |
163 | 172 |
164 TabControlFeature* BlimpClientSession::GetTabControlFeature() const { | 173 TabControlFeature* BlimpClientSession::GetTabControlFeature() const { |
165 return tab_control_feature_.get(); | 174 return tab_control_feature_.get(); |
166 } | 175 } |
167 | 176 |
168 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { | 177 NavigationFeature* BlimpClientSession::GetNavigationFeature() const { |
169 return navigation_feature_.get(); | 178 return navigation_feature_.get(); |
170 } | 179 } |
171 | 180 |
172 ImeFeature* BlimpClientSession::GetImeFeature() const { | 181 ImeFeature* BlimpClientSession::GetImeFeature() const { |
173 return ime_feature_.get(); | 182 return ime_feature_.get(); |
174 } | 183 } |
175 | 184 |
176 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { | 185 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const { |
177 return render_widget_feature_.get(); | 186 return render_widget_feature_.get(); |
178 } | 187 } |
179 | 188 |
180 SettingsFeature* BlimpClientSession::GetSettingsFeature() const { | 189 SettingsFeature* BlimpClientSession::GetSettingsFeature() const { |
181 return settings_feature_.get(); | 190 return settings_feature_.get(); |
182 } | 191 } |
183 | 192 |
184 } // namespace client | 193 } // namespace client |
185 } // namespace blimp | 194 } // namespace blimp |
OLD | NEW |