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

Side by Side Diff: chrome/browser/task_manager/sampling/task_manager_io_thread_helper.h

Issue 2905403002: plumb network upload into the task manager (Closed)
Patch Set: added refresh timer tests Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 14
15 namespace net { 15 namespace net {
16 class URLRequest; 16 class URLRequest;
17 } // namespace net 17 } // namespace net
18 18
19 namespace task_manager { 19 namespace task_manager {
20 20
21 // Defines a wrapper of values that will be sent from IO to UI thread upon 21 // Defines a wrapper of values that will be sent from IO to UI thread upon
22 // reception of bytes read notifications. 22 // reception of bytes read notifications.
ncarter (slow) 2017/06/17 00:21:01 "bytes read" is still read-specific
cburn 2017/06/19 22:07:08 Done.
23 struct BytesReadParam { 23 struct BytesTransferedParam {
24 // The PID of the originating process of the URLRequest, if the request is 24 // The PID of the originating process of the URLRequest, if the request is
25 // sent on behalf of another process. Otherwise it's 0. 25 // sent on behalf of another process. Otherwise it's 0.
26 int origin_pid; 26 int origin_pid;
27 27
28 // The unique ID of the host of the child process requestor. 28 // The unique ID of the host of the child process requestor.
29 int child_id; 29 int child_id;
30 30
31 // The ID of the IPC route for the URLRequest (this identifies the 31 // The ID of the IPC route for the URLRequest (this identifies the
32 // RenderView or like-thing in the renderer that the request gets routed 32 // RenderView or like-thing in the renderer that the request gets routed
33 // to). 33 // to).
34 int route_id; 34 int route_id;
35 35
36 // The number of bytes read. 36 // The number of bytes read.
37 int64_t byte_count; 37 int64_t byte_read_count;
38 38
39 BytesReadParam(int origin_pid, 39 // The number of bytes sent.
40 int child_id, 40 int64_t byte_sent_count;
41 int route_id, 41
42 int64_t byte_count) 42 BytesTransferedParam(int origin_pid,
43 int child_id,
44 int route_id,
45 int64_t byte_read_count,
46 int64_t byte_sent_count)
43 : origin_pid(origin_pid), 47 : origin_pid(origin_pid),
44 child_id(child_id), 48 child_id(child_id),
45 route_id(route_id), 49 route_id(route_id),
46 byte_count(byte_count) { 50 byte_read_count(byte_read_count),
47 } 51 byte_sent_count(byte_sent_count) {}
48 }; 52 };
49 53
50 // Defines a utility class used to schedule the creation and removal of the 54 // Defines a utility class used to schedule the creation and removal of the
51 // TaskManagerIoThreadHelper on the IO thread. 55 // TaskManagerIoThreadHelper on the IO thread.
52 class IoThreadHelperManager { 56 class IoThreadHelperManager {
53 public: 57 public:
54 IoThreadHelperManager(); 58 IoThreadHelperManager();
55 ~IoThreadHelperManager(); 59 ~IoThreadHelperManager();
56 60
57 private: 61 private:
58 DISALLOW_COPY_AND_ASSIGN(IoThreadHelperManager); 62 DISALLOW_COPY_AND_ASSIGN(IoThreadHelperManager);
59 }; 63 };
60 64
61 // Defines a class used by the task manager to receive notifications of the 65 // Defines a class used by the task manager to receive notifications of the
62 // network bytes read by the various tasks. 66 // network bytes read by the various tasks.
63 // This object lives entirely only on the IO thread. 67 // This object lives entirely only on the IO thread.
64 class TaskManagerIoThreadHelper { 68 class TaskManagerIoThreadHelper {
65 public: 69 public:
66 // Create and delete the instance of this class. They must be called on the IO 70 // Create and delete the instance of this class. They must be called on the IO
67 // thread. 71 // thread.
68 static void CreateInstance(); 72 static void CreateInstance();
69 static void DeleteInstance(); 73 static void DeleteInstance();
70 74
71 // This is used to forward the call to update the network bytes from the 75 // This is used to forward the call to update the network bytes with read
72 // TaskManagerInterface if the new task manager is enabled. 76 // bytes from the TaskManagerInterface if the new task manager is enabled.
73 static void OnRawBytesRead(const net::URLRequest& request, 77 static void OnRawBytesRead(const net::URLRequest& request,
74 int64_t bytes_read); 78 int64_t bytes_read);
75 79
80 // This is used to forward the call to update the network bytes with sent
81 // bytes from the TaskManagerInterface if the new task manager is enabled.
82 static void OnRawBytesSent(const net::URLRequest& request,
83 int64_t bytes_sent);
84
76 private: 85 private:
77 TaskManagerIoThreadHelper(); 86 TaskManagerIoThreadHelper();
78 ~TaskManagerIoThreadHelper(); 87 ~TaskManagerIoThreadHelper();
79 88
80 // We gather multiple notifications on the IO thread in one second before a 89 // We gather multiple notifications on the IO thread in one second before a
81 // call is made to the following function to start the processing. 90 // call is made to the following function to start the processing for
82 void OnMultipleBytesReadIO(); 91 // transfered bytes.
92 void OnMultipleBytesTransferedIO();
83 93
84 // This will update the task manager with the network bytes read. 94 // This will update the task manager with the network bytes read.
85 void OnNetworkBytesRead(const net::URLRequest& request, int64_t bytes_read); 95 void OnNetworkBytesTransfered(const net::URLRequest& request,
96 int64_t bytes_read,
97 int64_t bytes_sent);
86 98
87 // This buffer will be filled on IO thread with information about the number 99 // This buffer will be filled on IO thread with information about the number
88 // of bytes read from URLRequests. 100 // of bytes transfered from URLRequests.
89 std::vector<BytesReadParam> bytes_read_buffer_; 101 std::vector<BytesTransferedParam> bytes_transfered_buffer_;
90 102
91 base::WeakPtrFactory<TaskManagerIoThreadHelper> weak_factory_; 103 base::WeakPtrFactory<TaskManagerIoThreadHelper> weak_factory_;
92 104
93 DISALLOW_COPY_AND_ASSIGN(TaskManagerIoThreadHelper); 105 DISALLOW_COPY_AND_ASSIGN(TaskManagerIoThreadHelper);
94 }; 106 };
95 107
96 } // namespace task_manager 108 } // namespace task_manager
97 109
98 #endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_ 110 #endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698