Commit 13260d58 authored by mostynb's avatar mostynb Committed by Commit bot

favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/devtools

BUG=466848

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

Cr-Commit-Position: refs/heads/master@{#322339}
parent 419f2d3d
......@@ -433,14 +433,14 @@ AndroidDeviceManager::HandlerThread::instance_ = NULL;
// static
scoped_refptr<AndroidDeviceManager::HandlerThread>
AndroidDeviceManager::HandlerThread::GetInstance() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!instance_)
new HandlerThread();
return instance_;
}
AndroidDeviceManager::HandlerThread::HandlerThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
instance_ = this;
thread_ = new base::Thread(kDevToolsAdbBridgeThreadName);
base::Thread::Options options;
......@@ -463,7 +463,7 @@ void AndroidDeviceManager::HandlerThread::StopThread(
}
AndroidDeviceManager::HandlerThread::~HandlerThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
instance_ = NULL;
if (!thread_)
return;
......
......@@ -140,7 +140,7 @@ AndroidDeviceManager::AndroidWebSocket::AndroidWebSocket(
socket_impl_(nullptr),
delegate_(delegate),
weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(delegate_);
DCHECK(device_);
device_->sockets_.insert(this);
......@@ -150,13 +150,13 @@ AndroidDeviceManager::AndroidWebSocket::AndroidWebSocket(
}
AndroidDeviceManager::AndroidWebSocket::~AndroidWebSocket() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
Terminate();
}
void AndroidDeviceManager::AndroidWebSocket::SendFrame(
const std::string& message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(socket_impl_);
DCHECK(device_);
device_->message_loop_proxy_->PostTask(
......@@ -169,7 +169,7 @@ void AndroidDeviceManager::AndroidWebSocket::Connected(
int result,
const std::string& extensions,
scoped_ptr<net::StreamSocket> socket) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (result != net::OK || !socket.get()) {
OnSocketClosed();
return;
......@@ -187,18 +187,18 @@ void AndroidDeviceManager::AndroidWebSocket::Connected(
void AndroidDeviceManager::AndroidWebSocket::OnFrameRead(
const std::string& message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
delegate_->OnFrameRead(message);
}
void AndroidDeviceManager::AndroidWebSocket::OnSocketClosed() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
Terminate();
delegate_->OnSocketClosed();
}
void AndroidDeviceManager::AndroidWebSocket::Terminate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (socket_impl_) {
DCHECK(device_);
device_->message_loop_proxy_->DeleteSoon(FROM_HERE, socket_impl_);
......
......@@ -114,19 +114,19 @@ DevToolsAndroidBridge::DiscoveryRequest::DiscoveryRequest(
AndroidDeviceManager* device_manager,
const DeviceListCallback& callback)
: callback_(callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
device_manager->QueryDevices(
base::Bind(&DiscoveryRequest::ReceivedDevices, this));
}
DevToolsAndroidBridge::DiscoveryRequest::~DiscoveryRequest() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
callback_.Run(complete_devices_);
}
void DevToolsAndroidBridge::DiscoveryRequest::ReceivedDevices(
const AndroidDeviceManager::Devices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
for (const auto& device : devices) {
device->QueryDeviceInfo(
base::Bind(&DiscoveryRequest::ReceivedDeviceInfo, this, device));
......@@ -136,7 +136,7 @@ void DevToolsAndroidBridge::DiscoveryRequest::ReceivedDevices(
void DevToolsAndroidBridge::DiscoveryRequest::ReceivedDeviceInfo(
scoped_refptr<AndroidDeviceManager::Device> device,
const AndroidDeviceManager::DeviceInfo& device_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_refptr<RemoteDevice> remote_device =
new RemoteDevice(device->serial(), device_info);
complete_devices_.push_back(std::make_pair(device, remote_device));
......@@ -157,7 +157,7 @@ void DevToolsAndroidBridge::DiscoveryRequest::ReceivedVersion(
scoped_refptr<RemoteBrowser> browser,
int result,
const std::string& response) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (result < 0)
return;
// Parse version, append to package name if available,
......@@ -185,7 +185,7 @@ void DevToolsAndroidBridge::DiscoveryRequest::ReceivedPages(
scoped_refptr<RemoteBrowser> browser,
int result,
const std::string& response) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (result < 0)
return;
scoped_ptr<base::Value> value(base::JSONReader::Read(response));
......@@ -348,7 +348,7 @@ DevToolsAndroidBridge::AgentHostDelegate::GetOrCreateAgentHost(
const BrowserId& browser_id,
const std::string& debug_url,
bool is_web_view) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AgentHostDelegates::iterator it = bridge->host_delegates_.find(id);
if (it != bridge->host_delegates_.end())
return it->second->agent_host_;
......@@ -662,7 +662,7 @@ void DevToolsAndroidBridge::SendProtocolCommand(
const std::string& method,
scoped_ptr<base::DictionaryValue> params,
const base::Closure callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (debug_url.empty())
return;
scoped_refptr<AndroidDeviceManager::Device> device(
......@@ -711,7 +711,7 @@ void DevToolsAndroidBridge::RespondToOpenOnUIThread(
const RemotePageCallback& callback,
int result,
const std::string& response) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (result < 0) {
callback.Run(NULL);
return;
......@@ -729,7 +729,7 @@ void DevToolsAndroidBridge::OpenRemotePage(
scoped_refptr<RemoteBrowser> browser,
const std::string& input_url,
const DevToolsAndroidBridge::RemotePageCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GURL gurl(input_url);
if (!gurl.is_valid()) {
gurl = GURL("http://" + input_url);
......@@ -761,7 +761,7 @@ void DevToolsAndroidBridge::PageCreatedOnUIThread(
const std::string& url,
int result,
const std::string& response) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (result < 0)
return;
......@@ -780,7 +780,7 @@ void DevToolsAndroidBridge::NavigatePageOnUIThread(
int result,
const std::string& response,
const std::string& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_ptr<base::Value> value(base::JSONReader::Read(response));
base::DictionaryValue* dict;
......@@ -829,7 +829,7 @@ DevToolsAndroidBridge::DevToolsAndroidBridge(
task_scheduler_(base::Bind(&DevToolsAndroidBridge::ScheduleTaskDefault)),
port_forwarding_controller_(new PortForwardingController(profile, this)),
weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(prefs::kDevToolsDiscoverUsbDevicesEnabled,
base::Bind(&DevToolsAndroidBridge::CreateDeviceProviders,
......@@ -839,7 +839,7 @@ DevToolsAndroidBridge::DevToolsAndroidBridge(
void DevToolsAndroidBridge::AddDeviceListListener(
DeviceListListener* listener) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
bool polling_was_off = !NeedsDeviceListPolling();
device_list_listeners_.push_back(listener);
if (polling_was_off)
......@@ -848,7 +848,7 @@ void DevToolsAndroidBridge::AddDeviceListListener(
void DevToolsAndroidBridge::RemoveDeviceListListener(
DeviceListListener* listener) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DeviceListListeners::iterator it = std::find(
device_list_listeners_.begin(), device_list_listeners_.end(), listener);
DCHECK(it != device_list_listeners_.end());
......@@ -866,7 +866,7 @@ void DevToolsAndroidBridge::AddDeviceCountListener(
void DevToolsAndroidBridge::RemoveDeviceCountListener(
DeviceCountListener* listener) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DeviceCountListeners::iterator it = std::find(
device_count_listeners_.begin(), device_count_listeners_.end(), listener);
DCHECK(it != device_count_listeners_.end());
......@@ -896,12 +896,12 @@ void DevToolsAndroidBridge::RemovePortForwardingListener(
}
bool DevToolsAndroidBridge::HasDevToolsWindow(const std::string& agent_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return host_delegates_.find(agent_id) != host_delegates_.end();
}
DevToolsAndroidBridge::~DevToolsAndroidBridge() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(device_list_listeners_.empty());
DCHECK(device_count_listeners_.empty());
DCHECK(port_forwarding_listeners_.empty());
......@@ -924,7 +924,7 @@ bool DevToolsAndroidBridge::NeedsDeviceListPolling() {
void DevToolsAndroidBridge::RequestDeviceList(
const DeviceListCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!NeedsDeviceListPolling() ||
!callback.Equals(device_list_callback_.callback()))
......@@ -935,7 +935,7 @@ void DevToolsAndroidBridge::RequestDeviceList(
void DevToolsAndroidBridge::ReceivedDeviceList(
const CompleteDevices& complete_devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
device_map_.clear();
RemoteDevices remote_devices;
......@@ -976,7 +976,7 @@ void DevToolsAndroidBridge::StopDeviceCountPolling() {
void DevToolsAndroidBridge::RequestDeviceCount(
const base::Callback<void(int)>& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (device_count_listeners_.empty() ||
!callback.Equals(device_count_callback_.callback()))
......@@ -986,7 +986,7 @@ void DevToolsAndroidBridge::RequestDeviceCount(
}
void DevToolsAndroidBridge::ReceivedDeviceCount(int count) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DeviceCountListeners copy(device_count_listeners_);
for (DeviceCountListeners::iterator it = copy.begin(); it != copy.end(); ++it)
......
......@@ -323,7 +323,7 @@ PortForwardingController::Connection::Connection(
connected_(false),
forwarding_map_(forwarding_map),
weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
controller_->registry_[browser->serial()] = this;
scoped_refptr<AndroidDeviceManager::Device> device(
controller_->bridge_->FindDevice(browser->serial()));
......@@ -334,7 +334,7 @@ PortForwardingController::Connection::Connection(
}
PortForwardingController::Connection::~Connection() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(controller_->registry_.find(browser_->serial()) !=
controller_->registry_.end());
controller_->registry_.erase(browser_->serial());
......@@ -342,7 +342,7 @@ PortForwardingController::Connection::~Connection() {
void PortForwardingController::Connection::UpdateForwardingMap(
const ForwardingMap& new_forwarding_map) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (connected_) {
SerializeChanges(tethering::unbind::kName,
new_forwarding_map, forwarding_map_);
......@@ -356,7 +356,7 @@ void PortForwardingController::Connection::SerializeChanges(
const std::string& method,
const ForwardingMap& old_map,
const ForwardingMap& new_map) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
for (ForwardingMap::const_iterator new_it(new_map.begin());
new_it != new_map.end(); ++new_it) {
int port = new_it->first;
......@@ -371,7 +371,7 @@ void PortForwardingController::Connection::SerializeChanges(
void PortForwardingController::Connection::SendCommand(
const std::string& method, int port) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue);
if (method == tethering::bind::kName) {
params->SetInteger(tethering::bind::kParamPort, port);
......@@ -451,7 +451,7 @@ void PortForwardingController::Connection::UpdateSocketCountOnHandlerThread(
void PortForwardingController::Connection::UpdateSocketCount(
int port, int increment) {
#if defined(DEBUG_DEVTOOLS)
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
PortStatusMap::iterator it = port_status_.find(port);
if (it == port_status_.end())
return;
......@@ -463,12 +463,12 @@ void PortForwardingController::Connection::UpdateSocketCount(
const PortForwardingController::PortStatusMap&
PortForwardingController::Connection::GetPortStatusMap() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return port_status_;
}
void PortForwardingController::Connection::OnSocketOpened() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
connected_ = true;
SerializeChanges(tethering::bind::kName, ForwardingMap(), forwarding_map_);
}
......@@ -479,7 +479,7 @@ void PortForwardingController::Connection::OnSocketClosed() {
void PortForwardingController::Connection::OnFrameRead(
const std::string& message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (ProcessResponse(message))
return;
......
......@@ -586,7 +586,7 @@ class AndroidUsbDiscoveryTest : public InProcessBrowserTest {
}
void ScheduleDeviceCountRequest(const base::Closure& request) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scheduler_invoked_++;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, request);
}
......@@ -690,7 +690,7 @@ class MockCountListener : public DevToolsAndroidBridge::DeviceCountListener {
};
void ShutdownOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (reposts_left_-- == 0) {
base::MessageLoop::current()->Quit();
} else {
......@@ -703,7 +703,7 @@ class MockCountListener : public DevToolsAndroidBridge::DeviceCountListener {
}
void ShutdownOnFileThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(&MockCountListener::ShutdownOnUIThread,
......
......@@ -180,7 +180,7 @@ static void RespondOnFileThread(
const AndroidUsbDevicesCallback& callback,
AndroidUsbDevices* devices,
scoped_refptr<base::MessageLoopProxy> caller_message_loop_proxy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
caller_message_loop_proxy->PostTask(
FROM_HERE,
base::Bind(&RespondOnCallerThread, callback, devices));
......@@ -193,7 +193,7 @@ static void OpenAndroidDeviceOnFileThread(
scoped_refptr<UsbDevice> device,
int interface_id,
bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
if (success) {
base::string16 serial;
if (device->GetSerialNumber(&serial) && !serial.empty()) {
......@@ -215,7 +215,7 @@ static void OpenAndroidDeviceOnFileThread(
}
static int CountOnFileThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
UsbService* service = device::DeviceClient::Get()->GetUsbService();
UsbDevices usb_devices;
if (service != NULL)
......@@ -238,7 +238,7 @@ static void EnumerateOnFileThread(
crypto::RSAPrivateKey* rsa_key,
const AndroidUsbDevicesCallback& callback,
scoped_refptr<base::MessageLoopProxy> caller_message_loop_proxy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
UsbService* service = device::DeviceClient::Get()->GetUsbService();
UsbDevices usb_devices;
......@@ -612,7 +612,7 @@ void AndroidUsbDevice::TransferError(UsbTransferStatus status) {
void AndroidUsbDevice::TerminateIfReleased(
scoped_refptr<UsbDeviceHandle> usb_handle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
if (usb_handle->GetDevice().get())
return;
message_loop_->PostTask(FROM_HERE,
......
......@@ -52,7 +52,7 @@ base::WeakPtr<DevToolsBridgeClient> DevToolsBridgeClient::Create(
Profile* profile,
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto instance =
new DevToolsBridgeClient(profile, signin_manager, token_service);
return instance->weak_factory_.GetWeakPtr();
......@@ -67,7 +67,7 @@ DevToolsBridgeClient::DevToolsBridgeClient(
identity_provider_(signin_manager, token_service, nullptr),
worker_is_loaded_(false),
weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
identity_provider_.AddObserver(this);
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
......@@ -78,13 +78,13 @@ DevToolsBridgeClient::DevToolsBridgeClient(
}
DevToolsBridgeClient::~DevToolsBridgeClient() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
identity_provider_.RemoveObserver(this);
}
void DevToolsBridgeClient::DeleteSelf() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
delete this;
}
......@@ -178,7 +178,7 @@ DevToolsBridgeClient::DeviceInfo DevToolsBridgeClient::GetDeviceInfo(
}
void DevToolsBridgeClient::CreateBackgroundWorker() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
background_worker_.reset(
WebContents::Create(WebContents::CreateParams(profile_)));
......@@ -204,19 +204,19 @@ void DevToolsBridgeClient::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
delete this;
}
void DevToolsBridgeClient::OnActiveAccountLogin() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CreateBackgroundWorker();
}
void DevToolsBridgeClient::OnActiveAccountLogout() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
background_worker_.reset();
browser_list_request_.reset();
send_command_request_.reset();
......
......@@ -118,21 +118,21 @@ class SelectFileDialog : public ui::SelectFileDialog::Listener,
};
void WriteToFile(const base::FilePath& path, const std::string& content) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK(!path.empty());
base::WriteFile(path, content.c_str(), content.length());
}
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK(!path.empty());
base::AppendToFile(path, content.c_str(), content.size());
}
storage::IsolatedContext* isolated_context() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
storage::IsolatedContext* isolated_context =
storage::IsolatedContext::GetInstance();
DCHECK(isolated_context);
......@@ -142,7 +142,7 @@ storage::IsolatedContext* isolated_context() {
std::string RegisterFileSystem(WebContents* web_contents,
const base::FilePath& path,
std::string* registered_name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(web_contents->GetURL().SchemeIs(content::kChromeDevToolsScheme));
std::string file_system_id = isolated_context()->RegisterFileSystemForPath(
storage::kFileSystemTypeNativeLocal,
......@@ -410,7 +410,7 @@ void DevToolsFileHelper::RequestFileSystems(
}
void DevToolsFileHelper::RemoveFileSystem(const std::string& file_system_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
isolated_context()->RevokeFileSystemByPath(path);
......@@ -422,7 +422,7 @@ void DevToolsFileHelper::RemoveFileSystem(const std::string& file_system_path) {
bool DevToolsFileHelper::IsFileSystemAdded(
const std::string& file_system_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
set<std::string> file_system_paths = GetAddedFileSystemPaths(profile_);
return file_system_paths.find(file_system_path) != file_system_paths.end();
}
......@@ -137,7 +137,7 @@ Index::Index() : last_file_id_(0) {
Index::~Index() {}
Time Index::LastModifiedTimeForFile(const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
Time last_modified_time;
if (index_times_.find(file_path) != index_times_.end())
last_modified_time = index_times_[file_path];
......@@ -147,7 +147,7 @@ Time Index::LastModifiedTimeForFile(const FilePath& file_path) {
void Index::SetTrigramsForFile(const FilePath& file_path,
const vector<Trigram>& index,
const Time& time) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
FileId file_id = GetFileId(file_path);
vector<Trigram>::const_iterator it = index.begin();
for (; it != index.end(); ++it) {
......@@ -159,7 +159,7 @@ void Index::SetTrigramsForFile(const FilePath& file_path,
}
vector<FilePath> Index::Search(string query) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
const char* data = query.c_str();
vector<TrigramChar> trigram_chars;
trigram_chars.reserve(query.size());
......@@ -203,7 +203,7 @@ vector<FilePath> Index::Search(string query) {
}
FileId Index::GetFileId(const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
string file_path_str = file_path.AsUTF8Unsafe();
if (file_ids_.find(file_path) != file_ids_.end())
return file_ids_[file_path];
......@@ -212,7 +212,7 @@ FileId Index::GetFileId(const FilePath& file_path) {
}
void Index::NormalizeVectors() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
for (size_t i = 0; i < kTrigramCount; ++i) {
if (!is_normalized_[i]) {
std::sort(index_[i].begin(), index_[i].end());
......@@ -224,7 +224,7 @@ void Index::NormalizeVectors() {
}
void Index::PrintStats() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
LOG(ERROR) << "Index stats:";
size_t size = 0;
size_t maxSize = 0;
......@@ -267,7 +267,7 @@ DevToolsFileSystemIndexer::FileSystemIndexingJob::FileSystemIndexingJob(
DevToolsFileSystemIndexer::FileSystemIndexingJob::~FileSystemIndexingJob() {}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Start() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
......@@ -275,7 +275,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::Start() {
}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
Bind(&FileSystemIndexingJob::StopOnFileThread, this));
......@@ -286,7 +286,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::StopOnFileThread() {
}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::CollectFilesToIndex() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
if (stopped_)
return;
if (!file_enumerator_) {
......@@ -317,7 +317,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::CollectFilesToIndex() {
}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::IndexFiles() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
if (stopped_)
return;
if (indexing_it_ == file_path_times_.end()) {
......@@ -393,7 +393,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::OnRead(
void DevToolsFileSystemIndexer::FileSystemIndexingJob::FinishFileIndexing(
bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
CloseFile();
if (success) {
FilePath file_path = indexing_it_->first;
......@@ -441,7 +441,7 @@ DevToolsFileSystemIndexer::IndexPath(
const TotalWorkCallback& total_work_callback,
const WorkedCallback& worked_callback,
const DoneCallback& done_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_refptr<FileSystemIndexingJob> indexing_job =
new FileSystemIndexingJob(FilePath::FromUTF8Unsafe(file_system_path),
total_work_callback,
......@@ -454,7 +454,7 @@ DevToolsFileSystemIndexer::IndexPath(
void DevToolsFileSystemIndexer::SearchInPath(const string& file_system_path,
const string& query,
const SearchCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
......@@ -469,7 +469,7 @@ void DevToolsFileSystemIndexer::SearchInPathOnFileThread(
const string& file_system_path,
const string& query,
const SearchCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
vector<FilePath> file_paths = g_trigram_index.Get().Search(query);
vector<string> result;
FilePath path = FilePath::FromUTF8Unsafe(file_system_path);
......
......@@ -272,7 +272,7 @@ scoped_ptr<DevToolsTargetImpl> DevToolsTargetImpl::CreateForWebContents(
// static
void DevToolsTargetImpl::EnumerateAllTargets(Callback callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::set<WebContents*> tab_web_contents;
for (TabContentsIterator it; !it.done(); it.Next())
......
......@@ -132,14 +132,14 @@ class WorkerObserver
}
void NotifyOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WorkerObserver::NotifyOnUIThread, this));
}
void NotifyOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (callback_.is_null())
return;
callback_.Run();
......
......@@ -655,7 +655,7 @@ void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions(
void DevToolsUIBindings::IndexPath(int index_request_id,
const std::string& file_system_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
if (!file_helper_->IsFileSystemAdded(file_system_path)) {
IndexingDone(index_request_id, file_system_path);
......@@ -682,7 +682,7 @@ void DevToolsUIBindings::IndexPath(int index_request_id,
}
void DevToolsUIBindings::StopIndexing(int index_request_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
IndexingJobsMap::iterator it = indexing_jobs_.find(index_request_id);
if (it == indexing_jobs_.end())
return;
......@@ -693,7 +693,7 @@ void DevToolsUIBindings::StopIndexing(int index_request_id) {
void DevToolsUIBindings::SearchInPath(int search_request_id,
const std::string& file_system_path,
const std::string& query) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
if (!file_helper_->IsFileSystemAdded(file_system_path)) {
SearchCompleted(search_request_id,
......@@ -880,7 +880,7 @@ void DevToolsUIBindings::IndexingTotalWorkCalculated(
int request_id,
const std::string& file_system_path,
int total_work) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
base::FundamentalValue total_work_value(total_work);
......@@ -892,7 +892,7 @@ void DevToolsUIBindings::IndexingTotalWorkCalculated(
void DevToolsUIBindings::IndexingWorked(int request_id,
const std::string& file_system_path,
int worked) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
base::FundamentalValue worked_value(worked);
......@@ -903,7 +903,7 @@ void DevToolsUIBindings::IndexingWorked(int request_id,
void DevToolsUIBindings::IndexingDone(int request_id,
const std::string& file_system_path) {
indexing_jobs_.erase(request_id);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path);
CallClientFunction("DevToolsAPI.indexingDone", &request_id_value,
......@@ -914,7 +914,7 @@ void DevToolsUIBindings::SearchCompleted(
int request_id,
const std::string& file_system_path,
const std::vector<std::string>& file_paths) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::ListValue file_paths_value;
for (std::vector<std::string>::const_iterator it(file_paths.begin());
it != file_paths.end(); ++it) {
......
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