Commit f84bb8f4 authored by mostynb's avatar mostynb Committed by Commit bot

favor DCHECK_CURRENTLY_ON for better logs in extensions/

BUG=466848

Review URL: https://codereview.chromium.org/1032553009

Cr-Commit-Position: refs/heads/master@{#322238}
parent 16408c28
......@@ -35,7 +35,7 @@ const char kStopDiscoveryFailed[] = "Failed to stop discovery";
extensions::BluetoothEventRouter* GetEventRouter(BrowserContext* context) {
// Note: |context| is valid on UI thread only.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return extensions::BluetoothAPI::Get(context)->event_router();
}
......@@ -54,13 +54,13 @@ BluetoothAPI::GetFactoryInstance() {
// static
BluetoothAPI* BluetoothAPI::Get(BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return GetFactoryInstance()->Get(context);
}
BluetoothAPI::BluetoothAPI(content::BrowserContext* context)
: browser_context_(context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
EventRouter* event_router = EventRouter::Get(browser_context_);
event_router->RegisterObserver(this,
bluetooth::OnAdapterStateChanged::kEventName);
......@@ -72,7 +72,7 @@ BluetoothAPI::BluetoothAPI(content::BrowserContext* context)
BluetoothAPI::~BluetoothAPI() {}
BluetoothEventRouter* BluetoothAPI::event_router() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!event_router_) {
event_router_.reset(new BluetoothEventRouter(browser_context_));
}
......@@ -80,18 +80,18 @@ BluetoothEventRouter* BluetoothAPI::event_router() {
}
void BluetoothAPI::Shutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
EventRouter::Get(browser_context_)->UnregisterObserver(this);
}
void BluetoothAPI::OnListenerAdded(const EventListenerInfo& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (event_router()->IsBluetoothSupported())
event_router()->OnListenerAdded();
}
void BluetoothAPI::OnListenerRemoved(const EventListenerInfo& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (event_router()->IsBluetoothSupported())
event_router()->OnListenerRemoved();
}
......@@ -113,7 +113,7 @@ BluetoothGetDevicesFunction::~BluetoothGetDevicesFunction() {}
bool BluetoothGetDevicesFunction::DoWork(
scoped_refptr<BluetoothAdapter> adapter) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::ListValue* device_list = new base::ListValue;
SetResult(device_list);
......@@ -140,7 +140,7 @@ BluetoothGetDeviceFunction::~BluetoothGetDeviceFunction() {}
bool BluetoothGetDeviceFunction::DoWork(
scoped_refptr<BluetoothAdapter> adapter) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
scoped_ptr<GetDevice::Params> params(GetDevice::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
......
......@@ -20,18 +20,18 @@ const char kPlatformNotSupported[] =
extensions::BluetoothEventRouter* GetEventRouter(
content::BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return extensions::BluetoothAPI::Get(context)->event_router();
}
bool IsBluetoothSupported(content::BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return GetEventRouter(context)->IsBluetoothSupported();
}
void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback callback,
content::BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GetEventRouter(context)->GetAdapter(callback);
}
......@@ -47,7 +47,7 @@ BluetoothExtensionFunction::~BluetoothExtensionFunction() {
}
bool BluetoothExtensionFunction::RunAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!IsBluetoothSupported(browser_context())) {
SetError(kPlatformNotSupported);
......@@ -61,7 +61,7 @@ bool BluetoothExtensionFunction::RunAsync() {
void BluetoothExtensionFunction::RunOnAdapterReady(
scoped_refptr<device::BluetoothAdapter> adapter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DoWork(adapter);
}
......
......@@ -91,7 +91,7 @@ std::string StatusToString(BluetoothLowEnergyEventRouter::Status status) {
extensions::BluetoothLowEnergyEventRouter* GetEventRouter(
BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return extensions::BluetoothLowEnergyAPI::Get(context)->event_router();
}
......@@ -114,20 +114,20 @@ BluetoothLowEnergyAPI::GetFactoryInstance() {
// static
BluetoothLowEnergyAPI* BluetoothLowEnergyAPI::Get(BrowserContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return GetFactoryInstance()->Get(context);
}
BluetoothLowEnergyAPI::BluetoothLowEnergyAPI(BrowserContext* context)
: event_router_(new BluetoothLowEnergyEventRouter(context)) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
BluetoothLowEnergyAPI::~BluetoothLowEnergyAPI() {
}
void BluetoothLowEnergyAPI::Shutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
namespace core_api {
......@@ -139,7 +139,7 @@ BluetoothLowEnergyExtensionFunction::~BluetoothLowEnergyExtensionFunction() {
}
bool BluetoothLowEnergyExtensionFunction::RunAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!BluetoothManifestData::CheckLowEnergyPermitted(extension())) {
error_ = kErrorPermissionDenied;
......@@ -165,7 +165,7 @@ bool BluetoothLowEnergyExtensionFunction::RunAsync() {
}
bool BluetoothLowEnergyConnectFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -208,7 +208,7 @@ void BluetoothLowEnergyConnectFunction::ErrorCallback(
}
bool BluetoothLowEnergyDisconnectFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -245,7 +245,7 @@ void BluetoothLowEnergyDisconnectFunction::ErrorCallback(
}
bool BluetoothLowEnergyGetServiceFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -278,7 +278,7 @@ bool BluetoothLowEnergyGetServiceFunction::DoWork() {
}
bool BluetoothLowEnergyGetServicesFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -309,7 +309,7 @@ bool BluetoothLowEnergyGetServicesFunction::DoWork() {
}
bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -346,7 +346,7 @@ bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() {
}
bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -390,7 +390,7 @@ bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() {
}
bool BluetoothLowEnergyGetIncludedServicesFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -423,7 +423,7 @@ bool BluetoothLowEnergyGetIncludedServicesFunction::DoWork() {
}
bool BluetoothLowEnergyGetDescriptorFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -459,7 +459,7 @@ bool BluetoothLowEnergyGetDescriptorFunction::DoWork() {
}
bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -502,7 +502,7 @@ bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() {
}
bool BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -560,7 +560,7 @@ void BluetoothLowEnergyReadCharacteristicValueFunction::ErrorCallback(
}
bool BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -604,7 +604,7 @@ void BluetoothLowEnergyWriteCharacteristicValueFunction::ErrorCallback(
}
bool BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -652,7 +652,7 @@ void BluetoothLowEnergyStartCharacteristicNotificationsFunction::ErrorCallback(
}
bool BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -694,7 +694,7 @@ void BluetoothLowEnergyStopCharacteristicNotificationsFunction::ErrorCallback(
}
bool BluetoothLowEnergyReadDescriptorValueFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......@@ -751,7 +751,7 @@ void BluetoothLowEnergyReadDescriptorValueFunction::ErrorCallback(
}
bool BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BluetoothLowEnergyEventRouter* event_router =
GetEventRouter(browser_context());
......
......@@ -183,7 +183,7 @@ BluetoothSocketCreateFunction::BluetoothSocketCreateFunction() {}
BluetoothSocketCreateFunction::~BluetoothSocketCreateFunction() {}
bool BluetoothSocketCreateFunction::Prepare() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
params_ = bluetooth_socket::Create::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
......@@ -264,7 +264,7 @@ BluetoothSocketListenFunction::BluetoothSocketListenFunction() {}
BluetoothSocketListenFunction::~BluetoothSocketListenFunction() {}
bool BluetoothSocketListenFunction::Prepare() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!CreateParams())
return false;
socket_event_dispatcher_ = GetSocketEventDispatcher(browser_context());
......@@ -443,7 +443,7 @@ BluetoothSocketAbstractConnectFunction::
~BluetoothSocketAbstractConnectFunction() {}
bool BluetoothSocketAbstractConnectFunction::Prepare() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
params_ = bluetooth_socket::Connect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
......@@ -540,7 +540,7 @@ BluetoothSocketDisconnectFunction::BluetoothSocketDisconnectFunction() {}
BluetoothSocketDisconnectFunction::~BluetoothSocketDisconnectFunction() {}
bool BluetoothSocketDisconnectFunction::Prepare() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
params_ = bluetooth_socket::Disconnect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
return true;
......@@ -592,7 +592,7 @@ BluetoothSocketSendFunction::BluetoothSocketSendFunction()
BluetoothSocketSendFunction::~BluetoothSocketSendFunction() {}
bool BluetoothSocketSendFunction::Prepare() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
params_ = bluetooth_socket::Send::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
......
......@@ -355,7 +355,7 @@ void BluetoothSocketEventDispatcher::DispatchEvent(
void* browser_context_id,
const std::string& extension_id,
scoped_ptr<Event> event) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
reinterpret_cast<content::BrowserContext*>(browser_context_id);
......
......@@ -70,7 +70,7 @@ void GuestViewMessageFilter::OnAttachGuest(
int element_instance_id,
int guest_instance_id,
const base::DictionaryValue& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto manager = GuestViewManager::FromBrowserContext(browser_context_);
if (!manager)
return;
......@@ -86,7 +86,7 @@ void GuestViewMessageFilter::OnCreateMimeHandlerViewGuest(
const std::string& view_id,
int element_instance_id,
const gfx::Size& element_size) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto manager = GuestViewManager::FromBrowserContext(browser_context_);
if (!manager)
return;
......
......@@ -72,7 +72,7 @@ void ShellSpeechRecognitionManagerDelegate::GetDiagnosticInformation(
void ShellSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const content::SpeechRecognitionSessionContext& context =
SpeechRecognitionManager::GetInstance()->GetSessionContext(session_id);
......@@ -104,7 +104,7 @@ void ShellSpeechRecognitionManagerDelegate::CheckRenderViewType(
base::Callback<void(bool ask_user, bool is_allowed)> callback,
int render_process_id,
int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
const content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
bool allowed = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment