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

Unified Diff: chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc

Issue 1918423002: Fix TaskmanagerIoThreadHelper bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/task_management/sampling/task_manager_io_thread_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc
diff --git a/chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc b/chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc
index f50e298df2c942d45e5bca4232b93f023c542127..67e8649c9cf448f9f43b184b0ebf1b9e2ee8a4d0 100644
--- a/chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc
+++ b/chrome/browser/task_management/sampling/task_manager_io_thread_helper.cc
@@ -59,7 +59,7 @@ void TaskManagerIoThreadHelper::OnRawBytesRead(const net::URLRequest& request,
g_io_thread_helper->OnNetworkBytesRead(request, bytes_read);
}
-TaskManagerIoThreadHelper::TaskManagerIoThreadHelper() {
+TaskManagerIoThreadHelper::TaskManagerIoThreadHelper() : weak_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
}
@@ -67,18 +67,14 @@ TaskManagerIoThreadHelper::~TaskManagerIoThreadHelper() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
}
-// static
void TaskManagerIoThreadHelper::OnMultipleBytesReadIO() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- if (!g_io_thread_helper)
- return;
-
- DCHECK(!g_io_thread_helper->bytes_read_buffer_.empty());
+ DCHECK(!bytes_read_buffer_.empty());
std::vector<BytesReadParam>* bytes_read_buffer =
new std::vector<BytesReadParam>();
- g_io_thread_helper->bytes_read_buffer_.swap(*bytes_read_buffer);
+ bytes_read_buffer_.swap(*bytes_read_buffer);
content::BrowserThread::PostTask(
content::BrowserThread::UI,
@@ -114,9 +110,9 @@ void TaskManagerIoThreadHelper::OnNetworkBytesRead(
// delayed TaskManagerIoThreadHelper::OnMultipleBytesReadIO() process them
// after one second from now.
content::BrowserThread::PostDelayedTask(
- content::BrowserThread::IO,
- FROM_HERE,
- base::Bind(TaskManagerIoThreadHelper::OnMultipleBytesReadIO),
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&TaskManagerIoThreadHelper::OnMultipleBytesReadIO,
+ weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(1));
}
« no previous file with comments | « chrome/browser/task_management/sampling/task_manager_io_thread_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698