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

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

Issue 1284993005: Notify NetworkDelegate when bytes have been received over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed empty cronet OnRawBytesRead implementation Created 5 years, 4 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_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_ 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_ 6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER_H_
7 7
8 #include <stdint.h>
9
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 13
12 namespace net { 14 namespace net {
13 class URLRequest; 15 class URLRequest;
14 } // namespace net 16 } // namespace net
15 17
16 namespace task_management { 18 namespace task_management {
17 19
18 // Defines a wrapper of values that will be sent from IO to UI thread upon 20 // Defines a wrapper of values that will be sent from IO to UI thread upon
19 // reception of bytes read notifications. 21 // reception of bytes read notifications.
20 struct BytesReadParam { 22 struct BytesReadParam {
21 // The PID of the originating process of the URLRequest, if the request is 23 // The PID of the originating process of the URLRequest, if the request is
22 // sent on behalf of another process. Otherwise it's 0. 24 // sent on behalf of another process. Otherwise it's 0.
23 int origin_pid; 25 int origin_pid;
24 26
25 // The unique ID of the host of the child process requestor. 27 // The unique ID of the host of the child process requestor.
26 int child_id; 28 int child_id;
27 29
28 // The ID of the IPC route for the URLRequest (this identifies the 30 // 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 31 // RenderView or like-thing in the renderer that the request gets routed
30 // to). 32 // to).
31 int route_id; 33 int route_id;
32 34
33 // The number of bytes read. 35 // The number of bytes read.
34 int byte_count; 36 int64_t byte_count;
35 37
36 BytesReadParam(int origin_pid, 38 BytesReadParam(int origin_pid,
37 int child_id, 39 int child_id,
38 int route_id, 40 int route_id,
39 int byte_count) 41 int64_t byte_count)
40 : origin_pid(origin_pid), 42 : origin_pid(origin_pid),
41 child_id(child_id), 43 child_id(child_id),
42 route_id(route_id), 44 route_id(route_id),
43 byte_count(byte_count) { 45 byte_count(byte_count) {
44 } 46 }
45 }; 47 };
46 48
47 // Defines a utility class used to schedule the creation and removal of the 49 // Defines a utility class used to schedule the creation and removal of the
48 // TaskManagerIoThreadHelper on the IO thread. 50 // TaskManagerIoThreadHelper on the IO thread.
49 class IoThreadHelperManager { 51 class IoThreadHelperManager {
(...skipping 10 matching lines...) Expand all
60 // This object lives entirely only on the IO thread. 62 // This object lives entirely only on the IO thread.
61 class TaskManagerIoThreadHelper { 63 class TaskManagerIoThreadHelper {
62 public: 64 public:
63 // Create and delete the instance of this class. They must be called on the IO 65 // Create and delete the instance of this class. They must be called on the IO
64 // thread. 66 // thread.
65 static void CreateInstance(); 67 static void CreateInstance();
66 static void DeleteInstance(); 68 static void DeleteInstance();
67 69
68 // This is used to forward the call to update the network bytes from the 70 // This is used to forward the call to update the network bytes from the
69 // TaskManagerInterface if the new task manager is enabled. 71 // TaskManagerInterface if the new task manager is enabled.
70 static void OnRawBytesRead(const net::URLRequest& request, int bytes_read); 72 static void OnRawBytesRead(const net::URLRequest& request,
73 int64_t bytes_read);
71 74
72 private: 75 private:
73 TaskManagerIoThreadHelper(); 76 TaskManagerIoThreadHelper();
74 ~TaskManagerIoThreadHelper(); 77 ~TaskManagerIoThreadHelper();
75 78
76 // We gather multiple notifications on the IO thread in one second before a 79 // 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. 80 // call is made to the following function to start the processing.
78 static void OnMultipleBytesReadIO(); 81 static void OnMultipleBytesReadIO();
79 82
80 // This will update the task manager with the network bytes read. 83 // This will update the task manager with the network bytes read.
81 void OnNetworkBytesRead(const net::URLRequest& request, int bytes_read); 84 void OnNetworkBytesRead(const net::URLRequest& request, int64_t bytes_read);
82 85
83 // This buffer will be filled on IO thread with information about the number 86 // This buffer will be filled on IO thread with information about the number
84 // of bytes read from URLRequests. 87 // of bytes read from URLRequests.
85 std::vector<BytesReadParam> bytes_read_buffer_; 88 std::vector<BytesReadParam> bytes_read_buffer_;
86 89
87 DISALLOW_COPY_AND_ASSIGN(TaskManagerIoThreadHelper); 90 DISALLOW_COPY_AND_ASSIGN(TaskManagerIoThreadHelper);
88 }; 91 };
89 92
90 } // namespace task_management 93 } // namespace task_management
91 94
92 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER _H_ 95 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_MANAGER_IO_THREAD_HELPER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698