| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/task_management/sampling/task_manager_io_thread_helper.
h" | 5 #include "chrome/browser/task_management/sampling/task_manager_io_thread_helper.
h" |
| 6 | 6 |
| 7 #include "chrome/browser/task_management/sampling/task_manager_impl.h" | 7 #include "chrome/browser/task_management/sampling/task_manager_impl.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
| 10 | 10 |
| 11 namespace task_management { | 11 namespace task_management { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 TaskManagerIoThreadHelper* g_io_thread_helper = nullptr; | 15 TaskManagerIoThreadHelper* g_io_thread_helper = nullptr; |
| 16 | 16 |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 IoThreadHelperManager::IoThreadHelperManager() { | 19 IoThreadHelperManager::IoThreadHelperManager() { |
| 20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 21 | 21 |
| 22 content::BrowserThread::PostTask( | 22 content::BrowserThread::PostTask( |
| 23 content::BrowserThread::IO, | 23 content::BrowserThread::IO, |
| 24 FROM_HERE, | 24 FROM_HERE, |
| 25 base::Bind(&TaskManagerIoThreadHelper::CreateInstance)); | 25 base::Bind(&TaskManagerIoThreadHelper::CreateInstance)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 IoThreadHelperManager::~IoThreadHelperManager() { | 28 IoThreadHelperManager::~IoThreadHelperManager() { |
| 29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 29 // This may be called at exit time when the main thread is no longer |
| 30 // registered as the UI thread. |
| 31 DCHECK( |
| 32 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) || |
| 33 !content::BrowserThread::IsMessageLoopValid(content::BrowserThread::UI)); |
| 30 | 34 |
| 31 content::BrowserThread::PostTask( | 35 content::BrowserThread::PostTask( |
| 32 content::BrowserThread::IO, | 36 content::BrowserThread::IO, |
| 33 FROM_HERE, | 37 FROM_HERE, |
| 34 base::Bind(&TaskManagerIoThreadHelper::DeleteInstance)); | 38 base::Bind(&TaskManagerIoThreadHelper::DeleteInstance)); |
| 35 } | 39 } |
| 36 | 40 |
| 37 // static | 41 // static |
| 38 void TaskManagerIoThreadHelper::CreateInstance() { | 42 void TaskManagerIoThreadHelper::CreateInstance() { |
| 39 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 base::Bind(&TaskManagerIoThreadHelper::OnMultipleBytesReadIO, | 118 base::Bind(&TaskManagerIoThreadHelper::OnMultipleBytesReadIO, |
| 115 weak_factory_.GetWeakPtr()), | 119 weak_factory_.GetWeakPtr()), |
| 116 base::TimeDelta::FromSeconds(1)); | 120 base::TimeDelta::FromSeconds(1)); |
| 117 } | 121 } |
| 118 | 122 |
| 119 bytes_read_buffer_.push_back( | 123 bytes_read_buffer_.push_back( |
| 120 BytesReadParam(origin_pid, child_id, route_id, bytes_read)); | 124 BytesReadParam(origin_pid, child_id, route_id, bytes_read)); |
| 121 } | 125 } |
| 122 | 126 |
| 123 } // namespace task_management | 127 } // namespace task_management |
| OLD | NEW |