Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / task_management / sampling / task_manager_io_thread_helper.h
blobc756d4234b6681fffb66906ccf8e4fcd8648a044
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
8 #include <vector>
10 #include "base/macros.h"
12 namespace net {
13 class URLRequest;
14 } // namespace net
16 namespace task_management {
18 // Defines a wrapper of values that will be sent from IO to UI thread upon
19 // reception of bytes read notifications.
20 struct BytesReadParam {
21 // The PID of the originating process of the URLRequest, if the request is
22 // sent on behalf of another process. Otherwise it's 0.
23 int origin_pid;
25 // The unique ID of the host of the child process requestor.
26 int child_id;
28 // The ID of the IPC route for the URLRequest (this identifies the
29 // RenderView or like-thing in the renderer that the request gets routed
30 // to).
31 int route_id;
33 // The number of bytes read.
34 int byte_count;
36 BytesReadParam(int origin_pid,
37 int child_id,
38 int route_id,
39 int byte_count)
40 : origin_pid(origin_pid),
41 child_id(child_id),
42 route_id(route_id),
43 byte_count(byte_count) {
47 // Defines a utility class used to schedule the creation and removal of the
48 // TaskManagerIoThreadHelper on the IO thread.
49 class IoThreadHelperManager {
50 public:
51 IoThreadHelperManager();
52 ~IoThreadHelperManager();
54 private:
55 DISALLOW_COPY_AND_ASSIGN(IoThreadHelperManager);
58 // Defines a class used by the task manager to receive notifications of the
59 // network bytes read by the various tasks.
60 // This object lives entirely only on the IO thread.
61 class TaskManagerIoThreadHelper {
62 public:
63 // Create and delete the instance of this class. They must be called on the IO
64 // thread.
65 static void CreateInstance();
66 static void DeleteInstance();
68 // This is used to forward the call to update the network bytes from the
69 // TaskManagerInterface if the new task manager is enabled.
70 static void OnRawBytesRead(const net::URLRequest& request, int bytes_read);
72 private:
73 TaskManagerIoThreadHelper();
74 ~TaskManagerIoThreadHelper();
76 // We gather multiple notifications on the IO thread in one second before a
77 // call is made to the following function to start the processing.
78 static void OnMultipleBytesReadIO();
80 // This will update the task manager with the network bytes read.
81 void OnNetworkBytesRead(const net::URLRequest& request, int bytes_read);
83 // This buffer will be filled on IO thread with information about the number
84 // of bytes read from URLRequests.
85 std::vector<BytesReadParam> bytes_read_buffer_;
87 DISALLOW_COPY_AND_ASSIGN(TaskManagerIoThreadHelper);
90 } // namespace task_management
92 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_