| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/context/blimp_client_context_impl.h" | 5 #include "blimp/client/core/context/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "blimp/client/core/switches/blimp_client_switches.h" | 28 #include "blimp/client/core/switches/blimp_client_switches.h" |
| 29 #include "blimp/client/public/blimp_client_context_delegate.h" | 29 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 30 #include "blimp/client/public/compositor/compositor_dependencies.h" | 30 #include "blimp/client/public/compositor/compositor_dependencies.h" |
| 31 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
| 32 #include "device/geolocation/geolocation_delegate.h" | 32 #include "device/geolocation/geolocation_delegate.h" |
| 33 #include "device/geolocation/location_arbitrator.h" | 33 #include "device/geolocation/location_arbitrator.h" |
| 34 #include "ui/gfx/native_widget_types.h" | 34 #include "ui/gfx/native_widget_types.h" |
| 35 | 35 |
| 36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 37 #include "blimp/client/core/context/android/blimp_client_context_impl_android.h" | 37 #include "blimp/client/core/context/android/blimp_client_context_impl_android.h" |
| 38 #include "blimp/client/core/settings/android/settings_android.h" |
| 38 #endif // OS_ANDROID | 39 #endif // OS_ANDROID |
| 39 | 40 |
| 40 namespace blimp { | 41 namespace blimp { |
| 41 namespace client { | 42 namespace client { |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const char kDefaultAssignerUrl[] = | 46 const char kDefaultAssignerUrl[] = |
| 46 "https://blimp-pa.googleapis.com/v1/assignment"; | 47 "https://blimp-pa.googleapis.com/v1/assignment"; |
| 47 | 48 |
| 48 void DropConnectionOnIOThread(ClientNetworkComponents* net_components) { | 49 void DropConnectionOnIOThread(ClientNetworkComponents* net_components) { |
| 49 net_components->GetBrowserConnectionHandler()->DropCurrentConnection(); | 50 net_components->GetBrowserConnectionHandler()->DropCurrentConnection(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 } // namespace | 53 } // namespace |
| 53 | 54 |
| 54 // This function is declared in //blimp/client/public/blimp_client_context.h, | 55 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 55 // and either this function or the one in | 56 // and either this function or the one in |
| 56 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 57 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 57 // any binary using BlimpClientContext::Create. | 58 // any binary using BlimpClientContext::Create. |
| 58 // static | 59 // static |
| 59 BlimpClientContext* BlimpClientContext::Create( | 60 BlimpClientContext* BlimpClientContext::Create( |
| 60 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 61 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| 62 std::unique_ptr<CompositorDependencies> compositor_dependencies, | 63 std::unique_ptr<CompositorDependencies> compositor_dependencies, |
| 63 PrefService* local_state) { | 64 PrefService* local_state) { |
| 64 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
| 66 auto settings = base::MakeUnique<SettingsAndroid>(local_state); |
| 65 return new BlimpClientContextImplAndroid( | 67 return new BlimpClientContextImplAndroid( |
| 66 io_thread_task_runner, file_thread_task_runner, | 68 io_thread_task_runner, file_thread_task_runner, |
| 67 std::move(compositor_dependencies), local_state); | 69 std::move(compositor_dependencies), std::move(settings)); |
| 68 #else | 70 #else |
| 71 auto settings = base::MakeUnique<Settings>(local_state); |
| 69 return new BlimpClientContextImpl( | 72 return new BlimpClientContextImpl( |
| 70 io_thread_task_runner, file_thread_task_runner, | 73 io_thread_task_runner, file_thread_task_runner, |
| 71 std::move(compositor_dependencies), local_state); | 74 std::move(compositor_dependencies), std::move(settings)); |
| 72 #endif // defined(OS_ANDROID) | 75 #endif // defined(OS_ANDROID) |
| 73 } | 76 } |
| 74 | 77 |
| 75 // This function is declared in //blimp/client/public/blimp_client_context.h | 78 // This function is declared in //blimp/client/public/blimp_client_context.h |
| 76 // and either this function or the one in | 79 // and either this function or the one in |
| 77 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 80 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 78 // any binary using BlimpClientContext::RegisterPrefs. | 81 // any binary using BlimpClientContext::RegisterPrefs. |
| 79 // static | 82 // static |
| 80 void BlimpClientContext::RegisterPrefs(PrefRegistrySimple* registry) { | 83 void BlimpClientContext::RegisterPrefs(PrefRegistrySimple* registry) { |
| 81 Settings::RegisterPrefs(registry); | 84 Settings::RegisterPrefs(registry); |
| 82 } | 85 } |
| 83 | 86 |
| 84 // This function is declared in //blimp/client/public/blimp_client_context.h | 87 // This function is declared in //blimp/client/public/blimp_client_context.h |
| 85 // and either this function or the one in | 88 // and either this function or the one in |
| 86 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 89 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 87 // any binary using BlimpClientContext::ApplyBlimpSwitches. | 90 // any binary using BlimpClientContext::ApplyBlimpSwitches. |
| 88 // static | 91 // static |
| 89 void BlimpClientContext::ApplyBlimpSwitches(CommandLinePrefStore* store) { | 92 void BlimpClientContext::ApplyBlimpSwitches(CommandLinePrefStore* store) { |
| 90 Settings::ApplyBlimpSwitches(store); | 93 Settings::ApplyBlimpSwitches(store); |
| 91 } | 94 } |
| 92 | 95 |
| 93 BlimpClientContextImpl::BlimpClientContextImpl( | 96 BlimpClientContextImpl::BlimpClientContextImpl( |
| 94 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 97 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 95 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | 98 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| 96 std::unique_ptr<CompositorDependencies> compositor_dependencies, | 99 std::unique_ptr<CompositorDependencies> compositor_dependencies, |
| 97 PrefService* local_state) | 100 std::unique_ptr<Settings> settings) |
| 98 : BlimpClientContext(), | 101 : BlimpClientContext(), |
| 99 io_thread_task_runner_(io_thread_task_runner), | 102 io_thread_task_runner_(io_thread_task_runner), |
| 100 file_thread_task_runner_(file_thread_task_runner), | 103 file_thread_task_runner_(file_thread_task_runner), |
| 101 blimp_compositor_dependencies_( | 104 blimp_compositor_dependencies_( |
| 102 base::MakeUnique<BlimpCompositorDependencies>( | 105 base::MakeUnique<BlimpCompositorDependencies>( |
| 103 std::move(compositor_dependencies))), | 106 std::move(compositor_dependencies))), |
| 104 settings_(base::MakeUnique<Settings>(local_state)), | 107 settings_(std::move(settings)), |
| 105 blob_channel_feature_(new BlobChannelFeature(this)), | 108 blob_channel_feature_(new BlobChannelFeature(this)), |
| 106 geolocation_feature_(base::MakeUnique<GeolocationFeature>( | 109 geolocation_feature_(base::MakeUnique<GeolocationFeature>( |
| 107 base::MakeUnique<device::LocationArbitrator>( | 110 base::MakeUnique<device::LocationArbitrator>( |
| 108 base::MakeUnique<device::GeolocationDelegate>()))), | 111 base::MakeUnique<device::GeolocationDelegate>()))), |
| 109 ime_feature_(new ImeFeature), | 112 ime_feature_(new ImeFeature), |
| 110 navigation_feature_(new NavigationFeature), | 113 navigation_feature_(new NavigationFeature), |
| 111 render_widget_feature_(new RenderWidgetFeature), | 114 render_widget_feature_(new RenderWidgetFeature), |
| 112 settings_feature_(base::MakeUnique<SettingsFeature>(settings_.get())), | 115 settings_feature_(base::MakeUnique<SettingsFeature>(settings_.get())), |
| 113 tab_control_feature_(new TabControlFeature), | 116 tab_control_feature_(new TabControlFeature), |
| 114 blimp_contents_manager_( | 117 blimp_contents_manager_( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 141 | 144 |
| 142 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); | 145 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); |
| 143 } | 146 } |
| 144 | 147 |
| 145 BlimpClientContextImpl::~BlimpClientContextImpl() { | 148 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 146 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 149 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| 147 connection_status_.RemoveObserver(this); | 150 connection_status_.RemoveObserver(this); |
| 148 } | 151 } |
| 149 | 152 |
| 150 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 153 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
| 151 DCHECK(!delegate_ || !delegate); | 154 DCHECK(!delegate_ && delegate); |
| 152 delegate_ = delegate; | 155 delegate_ = delegate; |
| 153 | 156 |
| 154 // TODO(xingliu): Pass the IdentityProvider needed by |assignment_fetcher_| | 157 // TODO(xingliu): Pass the IdentityProvider needed by |assignment_fetcher_| |
| 155 // in the constructor, see crbug/661848. | 158 // in the constructor, see crbug/661848. |
| 156 if (delegate_) { | 159 if (delegate_) { |
| 157 assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>( | 160 assignment_fetcher_ = base::MakeUnique<AssignmentFetcher>( |
| 158 io_thread_task_runner_, file_thread_task_runner_, | 161 io_thread_task_runner_, file_thread_task_runner_, |
| 159 delegate_->CreateIdentityProvider(), GetAssignerURL(), | 162 delegate_->CreateIdentityProvider(), GetAssignerURL(), |
| 160 base::Bind(&BlimpClientContextImpl::OnAssignmentReceived, | 163 base::Bind(&BlimpClientContextImpl::OnAssignmentReceived, |
| 161 weak_factory_.GetWeakPtr()), | 164 weak_factory_.GetWeakPtr()), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (result >= 0) { | 278 if (result >= 0) { |
| 276 delegate_->OnEngineDisconnected(result); | 279 delegate_->OnEngineDisconnected(result); |
| 277 } else { | 280 } else { |
| 278 delegate_->OnNetworkDisconnected(result); | 281 delegate_->OnNetworkDisconnected(result); |
| 279 } | 282 } |
| 280 } | 283 } |
| 281 } | 284 } |
| 282 | 285 |
| 283 } // namespace client | 286 } // namespace client |
| 284 } // namespace blimp | 287 } // namespace blimp |
| OLD | NEW |