| 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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // static | 45 // static |
| 46 void TaskManagerIoThreadHelper::DeleteInstance() { | 46 void TaskManagerIoThreadHelper::DeleteInstance() { |
| 47 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 47 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 48 | 48 |
| 49 delete g_io_thread_helper; | 49 delete g_io_thread_helper; |
| 50 g_io_thread_helper = nullptr; | 50 g_io_thread_helper = nullptr; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 void TaskManagerIoThreadHelper::OnRawBytesRead(const net::URLRequest& request, | 54 void TaskManagerIoThreadHelper::OnRawBytesRead(const net::URLRequest& request, |
| 55 int bytes_read) { | 55 int64_t bytes_read) { |
| 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 57 | 57 |
| 58 if (g_io_thread_helper) | 58 if (g_io_thread_helper) |
| 59 g_io_thread_helper->OnNetworkBytesRead(request, bytes_read); | 59 g_io_thread_helper->OnNetworkBytesRead(request, bytes_read); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TaskManagerIoThreadHelper::TaskManagerIoThreadHelper() | 62 TaskManagerIoThreadHelper::TaskManagerIoThreadHelper() |
| 63 : bytes_read_buffer_() { | 63 : bytes_read_buffer_() { |
| 64 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 64 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 65 } | 65 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 82 g_io_thread_helper->bytes_read_buffer_.swap(*bytes_read_buffer); | 82 g_io_thread_helper->bytes_read_buffer_.swap(*bytes_read_buffer); |
| 83 | 83 |
| 84 content::BrowserThread::PostTask( | 84 content::BrowserThread::PostTask( |
| 85 content::BrowserThread::UI, | 85 content::BrowserThread::UI, |
| 86 FROM_HERE, | 86 FROM_HERE, |
| 87 base::Bind(&TaskManagerImpl::OnMultipleBytesReadUI, | 87 base::Bind(&TaskManagerImpl::OnMultipleBytesReadUI, |
| 88 base::Owned(bytes_read_buffer))); | 88 base::Owned(bytes_read_buffer))); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void TaskManagerIoThreadHelper::OnNetworkBytesRead( | 91 void TaskManagerIoThreadHelper::OnNetworkBytesRead( |
| 92 const net::URLRequest& request, int bytes_read) { | 92 const net::URLRequest& request, int64_t bytes_read) { |
| 93 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 93 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 94 | 94 |
| 95 // Only net::URLRequestJob instances created by the ResourceDispatcherHost | 95 // Only net::URLRequestJob instances created by the ResourceDispatcherHost |
| 96 // have an associated ResourceRequestInfo and a render frame associated. | 96 // have an associated ResourceRequestInfo and a render frame associated. |
| 97 // All other jobs will have -1 returned for the render process child and | 97 // All other jobs will have -1 returned for the render process child and |
| 98 // routing ids - the jobs may still match a resource based on their origin id, | 98 // routing ids - the jobs may still match a resource based on their origin id, |
| 99 // otherwise BytesRead() will attribute the activity to the Browser resource. | 99 // otherwise BytesRead() will attribute the activity to the Browser resource. |
| 100 const content::ResourceRequestInfo* info = | 100 const content::ResourceRequestInfo* info = |
| 101 content::ResourceRequestInfo::ForRequest(&request); | 101 content::ResourceRequestInfo::ForRequest(&request); |
| 102 int child_id = -1; | 102 int child_id = -1; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 119 FROM_HERE, | 119 FROM_HERE, |
| 120 base::Bind(TaskManagerIoThreadHelper::OnMultipleBytesReadIO), | 120 base::Bind(TaskManagerIoThreadHelper::OnMultipleBytesReadIO), |
| 121 base::TimeDelta::FromSeconds(1)); | 121 base::TimeDelta::FromSeconds(1)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bytes_read_buffer_.push_back( | 124 bytes_read_buffer_.push_back( |
| 125 BytesReadParam(origin_pid, child_id, route_id, bytes_read)); | 125 BytesReadParam(origin_pid, child_id, route_id, bytes_read)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace task_management | 128 } // namespace task_management |
| OLD | NEW |