Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: device/bluetooth/bluetooth_adapter_factory.cc

Issue 848613003: bluetooth: Shutdown BluetoothAdapter before DBus on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: --set-upstream-to=origin/master Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_adapter_factory.h" 5 #include "device/bluetooth/bluetooth_adapter_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
14 14
15 #if defined(OS_CHROMEOS)
16 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
17 #endif
18
15 #if defined(OS_MACOSX) 19 #if defined(OS_MACOSX)
16 #include "base/mac/mac_util.h" 20 #include "base/mac/mac_util.h"
17 #endif 21 #endif
18 22
19 namespace device { 23 namespace device {
20 24
21 namespace { 25 namespace {
22 26
23 // Shared default adapter instance. We don't want to keep this class around 27 // Shared default adapter instance. We don't want to keep this class around
24 // if nobody is using it, so use a WeakPtr and create the object when needed. 28 // if nobody is using it, so use a WeakPtr and create the object when needed.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 91 }
88 92
89 DCHECK(default_adapter.Get()->IsInitialized()); 93 DCHECK(default_adapter.Get()->IsInitialized());
90 #endif // defined(OS_WIN) 94 #endif // defined(OS_WIN)
91 95
92 if (default_adapter.Get()->IsInitialized()) 96 if (default_adapter.Get()->IsInitialized())
93 callback.Run(scoped_refptr<BluetoothAdapter>(default_adapter.Get().get())); 97 callback.Run(scoped_refptr<BluetoothAdapter>(default_adapter.Get().get()));
94 98
95 } 99 }
96 100
101 #if defined(OS_CHROMEOS)
102 // static
103 void BluetoothAdapterFactory::Shutdown() {
104 if (default_adapter.Get())
105 default_adapter.Get().get()->Shutdown();
106 }
107 #endif
108
97 // static 109 // static
98 void BluetoothAdapterFactory::SetAdapterForTesting( 110 void BluetoothAdapterFactory::SetAdapterForTesting(
99 scoped_refptr<BluetoothAdapter> adapter) { 111 scoped_refptr<BluetoothAdapter> adapter) {
100 default_adapter.Get() = adapter->GetWeakPtrForTesting(); 112 default_adapter.Get() = adapter->GetWeakPtrForTesting();
101 } 113 }
102 114
103 // static 115 // static
104 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() { 116 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() {
105 return default_adapter.Get(); 117 return default_adapter.Get();
106 } 118 }
107 119
108 } // namespace device 120 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_factory.h ('k') | device/bluetooth/bluetooth_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698