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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_extension_function.cc

Issue 1032553009: favor DCHECK_CURRENTLY_ON for better logs in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 "extensions/browser/api/bluetooth/bluetooth_extension_function.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_extension_function.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "device/bluetooth/bluetooth_adapter.h" 9 #include "device/bluetooth/bluetooth_adapter.h"
10 #include "device/bluetooth/bluetooth_adapter_factory.h" 10 #include "device/bluetooth/bluetooth_adapter_factory.h"
11 #include "extensions/browser/api/bluetooth/bluetooth_api.h" 11 #include "extensions/browser/api/bluetooth/bluetooth_api.h"
12 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" 12 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 namespace { 16 namespace {
17 17
18 const char kPlatformNotSupported[] = 18 const char kPlatformNotSupported[] =
19 "This operation is not supported on your platform"; 19 "This operation is not supported on your platform";
20 20
21 extensions::BluetoothEventRouter* GetEventRouter( 21 extensions::BluetoothEventRouter* GetEventRouter(
22 content::BrowserContext* context) { 22 content::BrowserContext* context) {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 23 DCHECK_CURRENTLY_ON(BrowserThread::UI);
24 return extensions::BluetoothAPI::Get(context)->event_router(); 24 return extensions::BluetoothAPI::Get(context)->event_router();
25 } 25 }
26 26
27 bool IsBluetoothSupported(content::BrowserContext* context) { 27 bool IsBluetoothSupported(content::BrowserContext* context) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 return GetEventRouter(context)->IsBluetoothSupported(); 29 return GetEventRouter(context)->IsBluetoothSupported();
30 } 30 }
31 31
32 void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback callback, 32 void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback callback,
33 content::BrowserContext* context) { 33 content::BrowserContext* context) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 34 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 GetEventRouter(context)->GetAdapter(callback); 35 GetEventRouter(context)->GetAdapter(callback);
36 } 36 }
37 37
38 } // namespace 38 } // namespace
39 39
40 namespace extensions { 40 namespace extensions {
41 namespace core_api { 41 namespace core_api {
42 42
43 BluetoothExtensionFunction::BluetoothExtensionFunction() { 43 BluetoothExtensionFunction::BluetoothExtensionFunction() {
44 } 44 }
45 45
46 BluetoothExtensionFunction::~BluetoothExtensionFunction() { 46 BluetoothExtensionFunction::~BluetoothExtensionFunction() {
47 } 47 }
48 48
49 bool BluetoothExtensionFunction::RunAsync() { 49 bool BluetoothExtensionFunction::RunAsync() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK_CURRENTLY_ON(BrowserThread::UI);
51 51
52 if (!IsBluetoothSupported(browser_context())) { 52 if (!IsBluetoothSupported(browser_context())) {
53 SetError(kPlatformNotSupported); 53 SetError(kPlatformNotSupported);
54 return false; 54 return false;
55 } 55 }
56 GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this), 56 GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this),
57 browser_context()); 57 browser_context());
58 58
59 return true; 59 return true;
60 } 60 }
61 61
62 void BluetoothExtensionFunction::RunOnAdapterReady( 62 void BluetoothExtensionFunction::RunOnAdapterReady(
63 scoped_refptr<device::BluetoothAdapter> adapter) { 63 scoped_refptr<device::BluetoothAdapter> adapter) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK_CURRENTLY_ON(BrowserThread::UI);
65 DoWork(adapter); 65 DoWork(adapter);
66 } 66 }
67 67
68 } // namespace core_api 68 } // namespace core_api
69 } // namespace extensions 69 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698