Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // NETWORK_ERROR Note: | 5 // NETWORK_ERROR Note: |
| 6 // When a device can't be found in the BluetoothAdapter, that generally | 6 // When a device can't be found in the BluetoothAdapter, that generally |
| 7 // indicates that it's gone out of range. We reject with a NetworkError in that | 7 // indicates that it's gone out of range. We reject with a NetworkError in that |
| 8 // case. | 8 // case. |
| 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt | 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne ctgatt |
| 10 | 10 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 // TODO(jyasskin): Add a way for tests to control the dialog | 164 // TODO(jyasskin): Add a way for tests to control the dialog |
| 165 // directly, and change this to a reasonable discovery timeout. | 165 // directly, and change this to a reasonable discovery timeout. |
| 166 base::TimeDelta::FromSecondsD(current_delay_time_), | 166 base::TimeDelta::FromSecondsD(current_delay_time_), |
| 167 base::Bind(&BluetoothDispatcherHost::StopDeviceDiscovery, | 167 base::Bind(&BluetoothDispatcherHost::StopDeviceDiscovery, |
| 168 // base::Timer guarantees it won't call back after its | 168 // base::Timer guarantees it won't call back after its |
| 169 // destructor starts. | 169 // destructor starts. |
| 170 base::Unretained(this)), | 170 base::Unretained(this)), |
| 171 /*is_repeating=*/false), | 171 /*is_repeating=*/false), |
| 172 weak_ptr_factory_(this) { | 172 weak_ptr_factory_(this) { |
| 173 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 173 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 174 | |
| 175 // Bind all future weak pointers to the UI thread. | |
| 176 weak_ptr_on_ui_thread_ = weak_ptr_factory_.GetWeakPtr(); | |
| 177 weak_ptr_on_ui_thread_.get(); | |
| 178 | |
| 174 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) | 179 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) |
| 175 BluetoothAdapterFactory::GetAdapter( | 180 BluetoothAdapterFactory::GetAdapter( |
| 176 base::Bind(&BluetoothDispatcherHost::set_adapter, | 181 base::Bind(&BluetoothDispatcherHost::set_adapter, |
| 177 weak_ptr_factory_.GetWeakPtr())); | 182 weak_ptr_factory_.GetWeakPtr())); |
|
qinmin
2015/10/05 18:38:54
use weak_ptr_on_ui_thread_ and everywhere else in
scheib
2015/10/05 21:01:33
Done. [Obviously] I didn't think of that, but it i
| |
| 178 } | 183 } |
| 179 | 184 |
| 180 void BluetoothDispatcherHost::OnDestruct() const { | 185 void BluetoothDispatcherHost::OnDestruct() const { |
| 181 // See class comment: UI Thread Note. | 186 // See class comment: UI Thread Note. |
| 182 BrowserThread::DeleteOnUIThread::Destruct(this); | 187 BrowserThread::DeleteOnUIThread::Destruct(this); |
| 183 } | 188 } |
| 184 | 189 |
| 185 void BluetoothDispatcherHost::OverrideThreadForMessage( | 190 void BluetoothDispatcherHost::OverrideThreadForMessage( |
| 186 const IPC::Message& message, | 191 const IPC::Message& message, |
| 187 content::BrowserThread::ID* thread) { | 192 content::BrowserThread::ID* thread) { |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 | 939 |
| 935 void BluetoothDispatcherHost::ShowBluetoothPairingLink() { | 940 void BluetoothDispatcherHost::ShowBluetoothPairingLink() { |
| 936 NOTIMPLEMENTED(); | 941 NOTIMPLEMENTED(); |
| 937 } | 942 } |
| 938 | 943 |
| 939 void BluetoothDispatcherHost::ShowBluetoothAdapterOffLink() { | 944 void BluetoothDispatcherHost::ShowBluetoothAdapterOffLink() { |
| 940 NOTIMPLEMENTED(); | 945 NOTIMPLEMENTED(); |
| 941 } | 946 } |
| 942 | 947 |
| 943 } // namespace content | 948 } // namespace content |
| OLD | NEW |