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

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

Issue 11075006: Moved bluetooth adapter files to device/bluetooth/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renamed 'bluetooth' target to 'device_bluetooth'. Created 8 years, 2 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 | Annotate | Revision Log
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 // TODO(youngki): Guard the ChromeOS specific part with "#ifdef CHROME_OS" block 5 #include "device/bluetooth/bluetooth_adapter_factory.h"
6 // once we move this code into common directory.
7 6
8 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_chromeos.h" 9 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_factory.h" 10 #include "device/bluetooth/bluetooth_adapter.h"
11
12 #if defined(OS_CHROMEOS)
13 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
14 #endif
12 15
13 namespace { 16 namespace {
14 17
15 // Shared default adapter instance, we don't want to keep this class around 18 // Shared default adapter instance, we don't want to keep this class around
16 // if nobody is using it so use a WeakPtr and create the object when needed; 19 // if nobody is using it so use a WeakPtr and create the object when needed;
17 // since Google C++ Style (and clang's static analyzer) forbids us having 20 // since Google C++ Style (and clang's static analyzer) forbids us having
18 // exit-time destructors we use a leaky lazy instance for it. 21 // exit-time destructors we use a leaky lazy instance for it.
19 base::LazyInstance<base::WeakPtr<chromeos::BluetoothAdapter> >::Leaky 22 base::LazyInstance<base::WeakPtr<device::BluetoothAdapter> >::Leaky
20 default_adapter = LAZY_INSTANCE_INITIALIZER; 23 default_adapter = LAZY_INSTANCE_INITIALIZER;
21 24
22 } // namespace 25 } // namespace
23 26
24 namespace chromeos { 27 namespace device {
25 28
26 // static 29 // static
27 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::DefaultAdapter() { 30 scoped_refptr<BluetoothAdapter> BluetoothAdapterFactory::DefaultAdapter() {
28 if (!default_adapter.Get().get()) { 31 if (!default_adapter.Get().get()) {
29 BluetoothAdapterChromeOs* new_adapter = new BluetoothAdapterChromeOs; 32 #if defined(OS_CHROMEOS)
33 chromeos::BluetoothAdapterChromeOs* new_adapter =
34 new chromeos::BluetoothAdapterChromeOs;
30 new_adapter->TrackDefaultAdapter(); 35 new_adapter->TrackDefaultAdapter();
31 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr(); 36 default_adapter.Get() = new_adapter->weak_ptr_factory_.GetWeakPtr();
37 #endif
32 } 38 }
33 39
34 return scoped_refptr<BluetoothAdapter>(default_adapter.Get()); 40 return scoped_refptr<BluetoothAdapter>(default_adapter.Get());
35 } 41 }
36 42
37 // static 43 // static
38 BluetoothAdapter* BluetoothAdapterFactory::Create(const std::string& address) { 44 BluetoothAdapter* BluetoothAdapterFactory::Create(const std::string& address) {
39 BluetoothAdapterChromeOs* adapter = new BluetoothAdapterChromeOs; 45 BluetoothAdapter* adapter = NULL;
40 adapter->FindAdapter(address); 46 #if defined(OS_CHROMEOS)
47 chromeos::BluetoothAdapterChromeOs* adapter_chromeos =
48 new chromeos::BluetoothAdapterChromeOs;
49 adapter_chromeos->FindAdapter(address);
50 adapter = adapter_chromeos;
51 #endif
41 return adapter; 52 return adapter;
42 } 53 }
43 54
44 } // namespace chromeos 55 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698