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

Side by Side Diff: content/browser/profiler_controller_impl.cc

Issue 1000373002: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[f-p]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/profiler_controller_impl.h" 5 #include "content/browser/profiler_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/process/process_handle.h" 8 #include "base/process/process_handle.h"
9 #include "base/tracked_objects.h" 9 #include "base/tracked_objects.h"
10 #include "content/common/child_process_messages.h" 10 #include "content/common/child_process_messages.h"
(...skipping 15 matching lines...) Expand all
26 26
27 ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) { 27 ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) {
28 } 28 }
29 29
30 ProfilerControllerImpl::~ProfilerControllerImpl() { 30 ProfilerControllerImpl::~ProfilerControllerImpl() {
31 } 31 }
32 32
33 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, 33 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number,
34 int pending_processes, 34 int pending_processes,
35 bool end) { 35 bool end) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK_CURRENTLY_ON(BrowserThread::UI);
37 if (subscriber_) 37 if (subscriber_)
38 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end); 38 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end);
39 } 39 }
40 40
41 void ProfilerControllerImpl::OnProfilerDataCollected( 41 void ProfilerControllerImpl::OnProfilerDataCollected(
42 int sequence_number, 42 int sequence_number,
43 const tracked_objects::ProcessDataSnapshot& profiler_data, 43 const tracked_objects::ProcessDataSnapshot& profiler_data,
44 int process_type) { 44 int process_type) {
45 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 45 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
46 BrowserThread::PostTask( 46 BrowserThread::PostTask(
47 BrowserThread::UI, FROM_HERE, 47 BrowserThread::UI, FROM_HERE,
48 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, 48 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected,
49 base::Unretained(this), 49 base::Unretained(this),
50 sequence_number, 50 sequence_number,
51 profiler_data, 51 profiler_data,
52 process_type)); 52 process_type));
53 return; 53 return;
54 } 54 }
55 55
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
57 if (subscriber_) { 57 if (subscriber_) {
58 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data, 58 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data,
59 process_type); 59 process_type);
60 } 60 }
61 } 61 }
62 62
63 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { 63 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK_CURRENTLY_ON(BrowserThread::UI);
65 DCHECK(!subscriber_); 65 DCHECK(!subscriber_);
66 subscriber_ = subscriber; 66 subscriber_ = subscriber;
67 } 67 }
68 68
69 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { 69 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) {
70 DCHECK_EQ(subscriber_, subscriber); 70 DCHECK_EQ(subscriber_, subscriber);
71 subscriber_ = NULL; 71 subscriber_ = NULL;
72 } 72 }
73 73
74 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( 74 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses(
75 int sequence_number) { 75 int sequence_number) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 76 DCHECK_CURRENTLY_ON(BrowserThread::IO);
77 77
78 int pending_processes = 0; 78 int pending_processes = 0;
79 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { 79 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
80 // In some cases, there may be no child process of the given type (for 80 // In some cases, there may be no child process of the given type (for
81 // example, the GPU process may not exist and there may instead just be a 81 // example, the GPU process may not exist and there may instead just be a
82 // GPU thread in the browser process). If that's the case, then the process 82 // GPU thread in the browser process). If that's the case, then the process
83 // handle will be base::kNullProcessHandle and we shouldn't ask it for data. 83 // handle will be base::kNullProcessHandle and we shouldn't ask it for data.
84 if (iter.GetData().handle == base::kNullProcessHandle) 84 if (iter.GetData().handle == base::kNullProcessHandle)
85 continue; 85 continue;
86 86
87 ++pending_processes; 87 ++pending_processes;
88 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number))) 88 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number)))
89 --pending_processes; 89 --pending_processes;
90 } 90 }
91 91
92 BrowserThread::PostTask( 92 BrowserThread::PostTask(
93 BrowserThread::UI, 93 BrowserThread::UI,
94 FROM_HERE, 94 FROM_HERE,
95 base::Bind( 95 base::Bind(
96 &ProfilerControllerImpl::OnPendingProcesses, 96 &ProfilerControllerImpl::OnPendingProcesses,
97 base::Unretained(this), 97 base::Unretained(this),
98 sequence_number, 98 sequence_number,
99 pending_processes, 99 pending_processes,
100 true)); 100 true));
101 } 101 }
102 102
103 void ProfilerControllerImpl::GetProfilerData(int sequence_number) { 103 void ProfilerControllerImpl::GetProfilerData(int sequence_number) {
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 104 DCHECK_CURRENTLY_ON(BrowserThread::UI);
105 105
106 int pending_processes = 0; 106 int pending_processes = 0;
107 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 107 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
108 !it.IsAtEnd(); it.Advance()) { 108 !it.IsAtEnd(); it.Advance()) {
109 ++pending_processes; 109 ++pending_processes;
110 if (!it.GetCurrentValue()->Send( 110 if (!it.GetCurrentValue()->Send(
111 new ChildProcessMsg_GetChildProfilerData(sequence_number))) { 111 new ChildProcessMsg_GetChildProfilerData(sequence_number))) {
112 --pending_processes; 112 --pending_processes;
113 } 113 }
114 } 114 }
115 OnPendingProcesses(sequence_number, pending_processes, false); 115 OnPendingProcesses(sequence_number, pending_processes, false);
116 116
117 BrowserThread::PostTask( 117 BrowserThread::PostTask(
118 BrowserThread::IO, 118 BrowserThread::IO,
119 FROM_HERE, 119 FROM_HERE,
120 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, 120 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses,
121 base::Unretained(this), 121 base::Unretained(this),
122 sequence_number)); 122 sequence_number));
123 } 123 }
124 124
125 } // namespace content 125 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/power_save_blocker_x11.cc ('k') | content/browser/push_messaging/push_messaging_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698